Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is Facebook PHP SDK getUser always returning 0?
    primarykey
    data
    text
    <p>I'm trying to work with a website that requires some information from a Facebook user, I'm using PHP and JS SDKs.</p> <p>I have a function in PHP:</p> <pre><code>public function isLoggedOnFacebook() { $user = $this-&gt;_facebook-&gt;getUser(); if ($user) { return $this-&gt;_facebook-&gt;api("/$user"); } return false; } </code></pre> <p>On a class that is holding the facebook object from the SDK in <code>$this-&gt;_facebook</code>.</p> <p>Then on a block I do this:</p> <pre><code>&lt;?php if (!$this-&gt;isLoggedOnFacebook()): ?&gt; &lt;div&gt; &lt;fb:login-button show-faces="true" perms="email" width="500" /&gt; &lt;/div&gt; &lt;?php endif ?&gt; </code></pre> <p>And the FB JS environment is properly set up (I think) so it works. So the user gets the pop up and authorizes the site.</p> <p>The problem is even after the app is been authorized by the user $user is always 0, meaning <code>$facebook-&gt;getUser()</code> always returns 0, and then lists the faces of users, including the logged user, but if I make it call <code>$facebook-&gt;api('/me')</code> or whatever, then it'll throw the invalid token exception.</p> <p>I've seen this problem, but I haven't seen a solution, I have no idea where the problem is and I run out of ideas.</p> <p>There's a Website tab on the developers' Facebook page in the apps section, where you can set up your Site URL and your Site Domain, and I'm thinking this are the cause of my problem, but I have no knowledge of exactly what these fields are supposed to contain.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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