src/lastfmapi/Api/UserApi.php
public function getFriends($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['user'])) {
            $vars = array(
                'method' => 'user.getfriends',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->friends->user) > 0) {
                    $i = 0;
                    foreach ($call->friends->user as $user) {
                        $friends[$i]['name'] = (string) $user->name;
                        $friends[$i]['images']['small'] = (string) $user->image[0];
                        $friends[$i]['images']['medium'] = (string) $user->image[1];
                        $friends[$i]['images']['large'] = (string) $user->image[2];
                        $friends[$i]['url'] = (string) $user->url;
                        if (!empty($recentTracks)) {
                            $friends[$i]['recenttrack']['artist']['name'] = (string) $user->recenttrack->artist->name;
                            $friends[$i]['recenttrack']['artist']['mbid'] = (string) $user->recenttrack->artist->mbid;
                            $friends[$i]['recenttrack']['artist']['url'] = (string) $user->recenttrack->artist->url;
                            $friends[$i]['recenttrack']['name'] = (string) $user->recenttrack->name;
                            $friends[$i]['recenttrack']['mbid'] = (string) $user->recenttrack->mbid;
                            $friends[$i]['recenttrack']['url'] = (string) $user->recenttrack->url;
                        }
                        $i++;
                    }

                    return $friends;
                } else {
                    throw new NoResultsException('This user has no friends');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist variable in the call for this method');
        }
    }
public function getFriends($methodVars)
    {
        // Check for required variables
        if (!empty($methodVars['user'])) {
            $vars = array(
                'method' => 'user.getfriends',
                'api_key' => $this->auth->apiKey
            );
            $vars = array_merge($vars, $methodVars);

            if ($call = $this->apiGetCall($vars)) {
                if (count($call->friends->user) > 0) {
                    $i = 0;
                    foreach ($call->friends->user as $user) {
                        $friends[$i]['name'] = (string) $user->name;
                        $friends[$i]['images']['small'] = (string) $user->image[0];
                        $friends[$i]['images']['medium'] = (string) $user->image[1];
                        $friends[$i]['images']['large'] = (string) $user->image[2];
                        $friends[$i]['url'] = (string) $user->url;
                        if (!empty($recentTracks)) {
                            $friends[$i]['recenttrack']['artist']['name'] = (string) $user->recenttrack->artist->name;
                            $friends[$i]['recenttrack']['artist']['mbid'] = (string) $user->recenttrack->artist->mbid;
                            $friends[$i]['recenttrack']['artist']['url'] = (string) $user->recenttrack->artist->url;
                            $friends[$i]['recenttrack']['name'] = (string) $user->recenttrack->name;
                            $friends[$i]['recenttrack']['mbid'] = (string) $user->recenttrack->mbid;
                            $friends[$i]['recenttrack']['url'] = (string) $user->recenttrack->url;
                        }
                        $i++;
                    }

                    return $friends;
                } else {
                    throw new NoResultsException('This user has no friends');
                }
            } else {
                return false;
            }
        } else {
            throw new InvalidArgumentException('You must include artist variable in the call for this method');
        }
    }
public function getFriends ( $ methodVars ) { // Check for required variables
 if ( ! empty ( $ methodVars [ 'user' ] ) ) { $ vars = array ( 'method' => 'user.getfriends' , 'api_key' => $ this -> auth -> apiKey ) ; $ vars = array_merge ( $ vars , $ methodVars ) ; if ( $ call = $ this -> apiGetCall ( $ vars ) ) { if ( count ( $ call -> friends -> user ) > 0 ) { $ i = 0 ; foreach ( $ call -> friends -> user as $ user ) { $ friends [ $ i ] [ 'name' ] = ( string ) $ user -> name ; $ friends [ $ i ] [ 'images' ] [ 'small' ] = ( string ) $ user -> image [ 0 ] ; $ friends [ $ i ] [ 'images' ] [ 'medium' ] = ( string ) $ user -> image [ 1 ] ; $ friends [ $ i ] [ 'images' ] [ 'large' ] = ( string ) $ user -> image [ 2 ] ; $ friends [ $ i ] [ 'url' ] = ( string ) $ user -> url ; if ( ! empty ( $ recentTracks ) ) { $ friends [ $ i ] [ 'recenttrack' ] [ 'artist' ] [ 'name' ] = ( string ) $ user -> recenttrack -> artist -> name ; $ friends [ $ i ] [ 'recenttrack' ] [ 'artist' ] [ 'mbid' ] = ( string ) $ user -> recenttrack -> artist -> mbid ; $ friends [ $ i ] [ 'recenttrack' ] [ 'artist' ] [ 'url' ] = ( string ) $ user -> recenttrack -> artist -> url ; $ friends [ $ i ] [ 'recenttrack' ] [ 'name' ] = ( string ) $ user -> recenttrack -> name ; $ friends [ $ i ] [ 'recenttrack' ] [ 'mbid' ] = ( string ) $ user -> recenttrack -> mbid ; $ friends [ $ i ] [ 'recenttrack' ] [ 'url' ] = ( string ) $ user -> recenttrack -> url ; } $ i ++ ; } return $ friends ; } else { throw new NoResultsException ( 'This user has no friends' ) ; } } else { return false ; } } else { throw new InvalidArgumentException ( 'You must include artist variable in the call for this method' ) ; } }
Get a list of the user's friends on Last.fm
@param array $methodVars An array with the following required values: <i>user</i>
@return array
Get a list of the user s friends on Last . fm