paquettg / leaguewrap

League of Legend API wrapper
MIT License
67 stars 28 forks source link

Getting too many results #63

Closed Huskeer closed 9 years ago

Huskeer commented 9 years ago

Can anyone help me out here. I just started using leaguewrap today, found it pretty useful so far for my needs. So i'm trying to pull a summoner's division and tier but what i'm getting in return are too many results that i can't really use properly. Perhaps my syntax is wrong:

require '../leaguewrap/vendor/autoload.php'; use LeagueWrap\Api; $api = new Api('key is here obviously'); $api->setRegion('euw'); $summoner = $api->summoner();
$test = $summoner->info('Summoner's Name here');

$league = $api->league(); $rank=$league->league($test->id);

So far so good but from here on my problems begin i cannot access the data on $rank so i ran a print_r and i got a rather interesting result. Upon searching with the summoner's id i get around 200 results. Perhaps there is something i am still not familiar with in the API?

Thanks.

dnlbauer commented 9 years ago

The reason for this is that league returns a list of all league entries for the summoners league. If you only want the entries that belongs to the summoner, you can add true as second parameter. The method is summoner($summonerId, $entry=false). On Feb 28, 2015 10:17 PM, "Huskeer" notifications@github.com wrote:

Can anyone help me out here. I just started using leaguewrap today, found it pretty useful so far for my needs. So i'm trying to pull a summoner's division and tier but what i'm getting in return are too many results that i can't really use properly. Perhaps my syntax is wrong:

require '../leaguewrap/vendor/autoload.php'; use LeagueWrap\Api; $api = new Api('key is here obviously'); $api->setRegion('euw'); $summoner = $api->summoner();

$test = $summoner->info('Summoner's Name here');

$league = $api->league(); $rank=$league->league($test->id);

So far so good but from here on my problems begin i cannot access the data on $rank so i ran a print_r and i got a rather interesting result. Upon searching with the summoner's id i get around 200 results. Perhaps there is something i am still not familiar with in the API? echo '

'.print_r($rank,true).'

';

Thanks.

— Reply to this email directly or view it on GitHub https://github.com/paquettg/leaguewrap/issues/63.

Huskeer commented 9 years ago

Works like charm. Thank you for the quick answer, and how do i access it if it's protected?

dnlbauer commented 9 years ago

Protected methods are usually methods that should not be called from the outside. They are internal functions. On Feb 28, 2015 10:58 PM, "Huskeer" notifications@github.com wrote:

Works like charm. Thank you for the quick answer, and how do i access it if it's protected?

— Reply to this email directly or view it on GitHub https://github.com/paquettg/leaguewrap/issues/63#issuecomment-76549193.

Huskeer commented 9 years ago

I know protected methods can't be accessed directly but why does it come like that in first place, it's only logical that someone would want to use them. Here's the answer to my first issue if anyone has the same problem: $rank=$league->league($test->id,$entry=true);