Answer the question
In order to leave comments, you need to log in
Facebook PHP SDK getUser always returns 0?
Hey!
The following problem occurred while authorizing a user on the site through the Facebook API.
The getUser function always returns 0, i.e. the user is not logged in, although it is not.
<br/>
<br/>
$config = array('appId' => 'XXXX', 'secret' => 'YYYYY');<br/>
$facebook = new Facebook($config);<br/>
$id = $facebook->getUser(); // Всегда 0<br/>
<br/>
/**<br/>
* Default options for curl.<br/>
*/<br/>
public static $CURL_OPTS = array(<br/>
<b>CURLOPT_CONNECTTIMEOUT => 10,</b><br/>
CURLOPT_RETURNTRANSFER => true,<br/>
CURLOPT_TIMEOUT => 60,<br/>
CURLOPT_USERAGENT => 'facebook-php-3.1',<br/>
);<br/>
<br/>
/**<br/>
* Default options for curl.<br/>
*/<br/>
public static $CURL_OPTS = array(<br/>
<b>CURLOPT_CONNECTTIMEOUT => 30,</b> <br/>
CURLOPT_RETURNTRANSFER => true,<br/>
CURLOPT_TIMEOUT => 60,<br/>
CURLOPT_USERAGENT => 'facebook-php-3.1',<br/>
);<br/>
Answer the question
In order to leave comments, you need to log in
Most likely, everything is much simpler than you think, today I just ran into this at work.
The Facebook API works over HTTPS. The Facebook SDK works through cUrl.
Therefore, you can try adding
cUrl to the settings. Helped me today.
CURLOPT_SSL_VERIFYPEER => 0
CURLOPT_SSL_VERIFYHOST => 0
I had a problem with getUser, the point was that this method checked the get parameters and the session for the presence of a user, if this data was not found, then all subsequent calls returned 0, until the next class initialization.
Maybe this is not your case, but still.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question