Adobe Facebook API calling "/me/picture" fails
I'm using the official Ad开发者_如何转开发obe Facebook API in my Flash/AS3 application and for some reason the call the /me/picture
seems to fail whereas the the call the /me/friends
seems to work just fine:
This works OK:
Facebook.api('/me/friends', onFriendsLoaded );
protected function onFriendsLoaded( response:Object, fail:Object ) : void
{
// I can get the friends from the response object
}
This fails:
Facebook.api('/me/picture', onPictureLoaded );
protected function onPictureLoaded( response:Object, fail:Object ) : void
{
// Here response is null and fail is ÿØÿà
}
I'm calling both methods right after each other. What could be the problem?
The /me/picture call is actually not an api call at all. http://graph.facebook.com/me/picture is the url of the photo. You can actually set an image to that url. I am not an expert in Flash, but if you were doing this in html you would do the following:
<img src="http://graph.facebook.com/facebook_id/picture" />
This would show the users picture. Additionally, if you wanted to download the picture's bytes you would just make a normal web request. The response stream would be the image file.
Try this way
function onPictureLoaded(response:Object,fail:Object):void{
if (fail)
{
trace("Error");
}
var friends = response as Array;
var l:int = friends.length;
for (var i:int=0; i < l; i++)
{
trace("http://graph.facebook.com/" + friends[i].id + "/picture/")
}
}
精彩评论