neetu
neetu

Reputation: 107

how to replace Facebook app image with profile pic using graph API?

i use this code but its not working

$uid =$facebook->getUser(); 
$picture="http://graph.facebook.com/".$uid."/picture?type=large";

Upvotes: 0

Views: 179

Answers (1)

Philip
Philip

Reputation: 5021

The code you share, is a Graph API call to get the User Picture,
you can use this function to get the user picture:

function avatar($id,$size) {
    if ($size) {
        $size = '?type='.$size.'';
    }
    return '<img src="https://graph.facebook.com/'.$id.'/picture'.$size.'" alt="" />';
}

i pass a second variable for the picture size, so you can use it like this:

echo avatar($uid,'square');

Upvotes: 2

Related Questions