I would like to display the users profile picture inside of my applications canvas page, is there a way to do that using the graph api?
I know I can do it using FBML but I would also like to pass the profile pic to a flash game I am making, so I would have to get the profile pic from the api and send it as a variable, here is the code I have thus far,
$facebook = new Facebook(array( 'appId' => FACEBOOK_APP_ID, 'secret' => FACEBOOK_SECRET_KEY, 'cookie' => true, 'domain' => 'myurl/facebook-test' )); $session = $facebook->getSession(); $uid = $facebook->getUser(); $me = $facebook->api('/me'); $updated = date("l, F j, Y", strtotime($me['updated_time'])); echo "Hello " . $me['name'] . $me['picture'] . "<br />"; echo "<div style=\"background:url(images/bg.jpg); width:760px; height:630px;\">" . "You last updated your profile on " . $updated . "</div>" . "<br /> your uid is" . $uid;
$me['picture']
does not seem to be working, but I am still very new to the graph api, and I am probably making a few very amateur mistakes!
Publishing an Photo With that granted, you can upload a photo by issuing an HTTP POST request with the photo content and an optional description to one these to Graph API connections: https://graph.facebook.com/USER_ID/photos - The photo will be published to an album created for your app.
The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.
Knowing the user id the URL for their profile picture is:-
http://graph.facebook.com/[UID]/picture
where in place of [UID] you place your $uid variable, and that URL can be passed to flash
to get different sizes, you can use the type parameter:
You can specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), and large (about 200 pixels wide, variable height): http://graph.facebook.com/squall3d/picture?type=large.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With