Quantcast
Channel: Active questions tagged news-feed+facebook+json - Stack Overflow
Viewing all articles
Browse latest Browse all 10

Getting the Image link from the Facebook (Page) JSON or Rss Feed

0
0

I am trying to get all the posts on my Facebook page. I know we can get the feeds in JSON or RSS format for a page but I am having issue in identifying and parsing the post's image Link. For example here is the link to the JSON feeds of my page Facebook Page JSON Feed.

Below is the format you can see there.

{
   "title": "Shorts Fashion's Facebook Wall",
   "link": "https:\/\/www.facebook.com\/",
   "self": "https:\/\/www.facebook.com\/feeds\/page.php?id=717795881626394&format=json",
   "updated": "2014-11-13T10:30:07-08:00",
   "icon": "http:\/\/www.facebook.com\/favicon.ico",
   "entries": [
      {
         "title": " Like <3",
         "id": "78d3340189c23524385e0522f6336f03",
         "alternate": "http:\/\/www.facebook.com\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780062908733024\/?type=1",
         "categories": [

         ],
         "published": "2014-11-13T18:30:07+00:00",
         "updated": "2014-11-13T18:30:07+00:00",
         "author": {
            "name": "Shorts Fashion"
         },
         "verb": "",
         "target": "",
         "objects": "",
         "comments": "",
         "likes": "",
         "content": "Like \u2665\u003Cbr\/>\u003Cbr\/>\u003Ca href=\"\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780062908733024\/?type=1&relevant_count=1\" id=\"\" title=\"\" target=\"\" onclick=\"\" style=\"\">\u003Cimg class=\"img\" src=\"https:\/\/scontent-b-kul.xx.fbcdn.net\/hphotos-xap1\/v\/t1.0-9\/s130x130\/10411933_780062908733024_2963383477612486789_n.jpg?oh=edcaf58eabb7f3fc88046bab3d5ddb5c&oe=54EA4DE2\" alt=\"\" \/>\u003C\/a>\u003Cbr\/>"
      },
      {
         "title": "<3 <3<3 <3<3 <3",
         "id": "adfedefb63af7a5443db66e19807f8fc",
         "alternate": "http:\/\/www.facebook.com\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780058738733441\/?type=1",
         "categories": [

Using the method below I can get the Title of the post but I am not sure that how to get the Image link from each post. Can some please help me with it. Thanks

$url = "http://www.facebook.com/feeds/page.php?id=717795881626394&format=json";
// disguises the curl using fake headers and a fake user agent.
function disguise_curl($url)
{
$curl = curl_init();

$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; // browsers keep this blank.

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_REFERER, '');
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);

$html = curl_exec($curl); // execute the curl command
curl_close($curl); // close the connection

return $html; // and finally, return $html
}

// uses the function and displays the text off the website
$text = disguise_curl($url);

$json_feed_object = json_decode($text);


foreach ( $json_feed_object->entries as $entry )
{
echo " {$entry->title}";
echo "<br>";
}

I want to get images from my page FEED to display on my website and android app. Thanks


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images