I am using Facebook Graph API to get the user's cover picture. The information you get with the link https://graph.facebook.com/facebookuserid?fields=cover is a JSON object, where the link to the picture is included. How do I obtain that link with JQuery or JavaScript?
This is what I've tried:
HTML:
<div id="cover"></div>
JQuery:
$(document).ready(function(){
var URL = 'https://graph.facebook.com/<?= $user ?>?fields=cover';
$.ajax({
url : URL,
dataType : "jsonp",
success : function(parsed_json) {
var coverpic = parsed_json["cover"]["source"];
$("#cover").append('<img src="' + coverpic + '"/>");
}
});
});
Where $user
is the PHP code $user = $facebook->getUser();
that gives me the ID of the current user.
Thanks.