Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can do this two ways: on the server-side (in PHP in your case) or on the client-side with the JavaScript SDK.</p> <p>Both assume you have the required access credentials. You need to sign up for an application account to get these at the <a href="http://developers.facebook.com/" rel="nofollow">Facebook Developer site</a></p> <h2>Server-Side</h2> <p>First-step is to get your application to participate in the OAuth authentication process. This is well-documented for PHP in the <a href="http://developers.facebook.com/docs/authentication/" rel="nofollow">Facebook guide</a> (see the Server-Side Flow section).</p> <p>Once you've done that, you'll have an access token that you can call into the Graph API with. The endpoint to get the user's photos is <code>https://graph.facebook.com/me/photos?access_token=&lt;token&gt;</code>. In this case the <code>me</code>, is always the user who signed in to give your application the token.</p> <p>In PHP, assuming you've stored the access token in <code>$SESSION['token']</code> you can make a request for the photos payload with:</p> <pre><code>$url = "https://graph.facebook.com/me/photos?access_token=" . $SESSION['token']; $photos = json_decode(file_get_contents($url)); </code></pre> <p>The <code>$photos</code> object will be a list of <code>Photo</code> entities that are described in the <a href="http://developers.facebook.com/docs/reference/api/photo/" rel="nofollow">Facebook docs</a>.</p> <h2>Client-Side</h2> <p>You'll need to setup the JavaScript SDK on your web pages as documented <a href="http://developers.facebook.com/docs/reference/javascript/" rel="nofollow">here</a>.</p> <p>Authentication on the client-side is handled by JavaScript SDK, again documented in the <a href="http://developers.facebook.com/" rel="nofollow">authentication guide</a>.</p> <p>Using the SDK, you can make a client-side JavaScript call to the Graph API for the same photos structure:</p> <pre><code>FB.api('/me/photos', function(response) { if(!response || response.error) { // render error } else { // render photos } }); </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