Note that there are some explanatory texts on larger screens.

plurals
  1. POShow images from facebook using PHP and graph api photos
    text
    copied!<p>I am trying to show my thumbnails of photos from my facebook fan page. I have studied the facebook dev and graph api. Now I am trying to using php to automate the process and show the images on my photo page. </p> <pre><code>$facebook_album = file_get_contents("https://graph.facebook.com/10150101465621686/photos"); </code></pre> <p>which returns the following data with the image data repeating for each image (see below):</p> <pre><code>{ "data": [ { "id": "10150101465701686", "from": { "name": "Lingua Language Academy", "category": "Organization", "id": "55206251685" }, "picture": "http://photos-d.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_s.jpg", "source": "http://a4.sphotos.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_n.jpg", "height": 540, "width": 720, "images": [ { "height": 540, "width": 720, "source": "http://a4.sphotos.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_n.jpg" }, { "height": 135, "width": 180, "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_a.jpg" }, { "height": 97, "width": 130, "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_s.jpg" }, { "height": 56, "width": 75, "source": "http://photos-d.ak.fbcdn.net/hphotos-ak-ash4/185883_10150101465701686_55206251685_6497497_7724100_t.jpg" } ], "link": "http://www.facebook.com/photo.php?pid=6497497&amp;id=55206251685", "icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif", "created_time": "2011-02-22T02:41:02+0000", "position": 1, "updated_time": "2011-02-22T02:41:04+0000" }, </code></pre> <p>My questions is... Is there an easy way to put the following info in an array that will be easy to loop through? </p> <p>Something like so that it loops through the data and puts the value of picture in the image src. </p> <pre><code>foreach( $facebook_album as $key =&gt; $value){ echo "&lt;img src='picture'/&gt;&lt;br /&gt;"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload