psn-php icon indicating copy to clipboard operation
psn-php copied to clipboard

Invalid argument supplied for foreach on avatarUrl

Open vicegold opened this issue 2 years ago • 2 comments

Both avatarUrl and avatarUrls return this error Invalid argument supplied for foreach on line 160 in tustin/psn-php/src/Model/User.php when using search() on 3.0.

vicegold avatar May 14 '22 08:05 vicegold

Could you provide some code?

The code seems to be working pretty fine.

Here are the code for avatars for a single user:

$username = 'psnuserhere';

$acc = $client->users()->search($username)->first()->accountId();
$user = $client->users()->find($acc);

var_dump($user->avatarUrls());

foreach ($user->avatarUrls() as $avatarUrl) {
    echo $avatarUrl;
}

Or in case you are trying to search the users and get their avatars:

$searchTerm = 'psnuserhere'
$users = $client->users()->search($searchTerm );

foreach ($users as $user) {
    var_dump($user->avatarUrls());
}

gabetavares avatar May 22 '22 05:05 gabetavares

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 31 '22 17:07 stale[bot]