I got the following code in PHP:
<?php
$json = file_get_contents('https://graph.facebook.com/192655950766049');
$data = json_decode($json, true);
echo $data['description'];
?>
and I want the equivalent code in JQuery.
I tried to do it myself but I had no luck.
Here’s one of my many tries:
<script type="text/javascript" src="../scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$.getJSON("https://graph.facebook.com/192655950766049", function(json) {
alert("JSON Data: " + json.description);
});
</script>
I read the explanation from http://api.jquery.com/jQuery.getJSON/, but yet I dont really understand it..
anyway, if you can help me it’ll be very nice!
Thanks
You need to use jquery’s jsonp request. See this short discussion on how to interface with facebook using this. JSONP allows for XSS ignoring the same origin policy.
Basically your code would then look similar to this: