Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>There is data called 'session' in the URL. Does this need to be stored in order to continually get the user ID?</em></p> <p>Yes, it needs to be stored, but the Facebook class parses it and stores it in a cookie for you.</p> <hr> <p><em>Also, would it be easier to just cut out the PHP library altogether and just handle the reponse myself, storing it in a session variable.</em></p> <p>The <code>Facebook</code> class provided in <strong>facebook.php</strong> is not necessary to use the API but provides a few conveniences for you, such as putting together common URLs, parsing session data (which is sent to the URL and then stored in a cookie), turning error messages (a JSON object with an "error" key) into a PHP Exception, etc.</p> <p>So, in short, no, it wouldn't be easier to cut out the PHP library because you'd end up writing basically the same stuff.</p> <p>As you can see from the example, they are getting the User ID (<code>$uid</code>) by calling <code>getUser</code>:</p> <pre><code>if ($session) { try { $uid = $facebook-&gt;getUser(); $me = $facebook-&gt;api('/me'); } catch (FacebookApiException $e) { error_log($e); } } </code></pre> <p>$uid is just an integer, and <code>$me</code> is the data for the current user (which it sounds like you don't need). The same data could be retrieved by calling:</p> <pre><code>$me = $facebook-&gt;api('/' . $uid); //Generates https://graph.facebook.com/[uid] </code></pre> <p>The problem I have right now with the example is that the curl function inside the Facebook class (<code>makeRequest</code> method) is for some reason returning NO content. So, <code>$me</code> is ending up with nothing, which makes the example still say <em>"You are not connected".</em> But, if you were to output <code>$uid</code>, you would see that it does indeed contain the current user's ID.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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