A
A
Anton2011-11-30 09:13:28
PHP
Anton, 2011-11-30 09:13:28

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' =&gt; 'XXXX', 'secret' =&gt; 'YYYYY');<br/>
$facebook = new Facebook($config);<br/>
$id = $facebook-&gt;getUser(); // Всегда 0<br/>

It is advised to do this, in the base_facebook.php file, change
<br/>
 /**<br/>
 * Default options for curl.<br/>
 */<br/>
 public static $CURL_OPTS = array(<br/>
 <b>CURLOPT_CONNECTTIMEOUT =&gt; 10,</b><br/>
 CURLOPT_RETURNTRANSFER =&gt; true,<br/>
 CURLOPT_TIMEOUT =&gt; 60,<br/>
 CURLOPT_USERAGENT =&gt; 'facebook-php-3.1',<br/>
 );<br/>

replaced by
<br/>
 /**<br/>
 * Default options for curl.<br/>
 */<br/>
 public static $CURL_OPTS = array(<br/>
 <b>CURLOPT_CONNECTTIMEOUT =&gt; 30,</b> <br/>
 CURLOPT_RETURNTRANSFER =&gt; true,<br/>
 CURLOPT_TIMEOUT =&gt; 60,<br/>
 CURLOPT_USERAGENT =&gt; 'facebook-php-3.1',<br/>
 );<br/>

It helped, but the request for the same function takes more than 20 seconds. And even then not for long, again began to return 0.
Maybe someone came across?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Valery, 2011-11-30
@AntonMinsk

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

R
rakot, 2011-11-30
@rakot

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.

D
Denis D., 2013-04-06
@denysd

Added values:
CURLOPT_SSL_VERIFYPEER => 0
CURLOPT_SSL_VERIFYHOST => 0

Didn't help( How else can I solve the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question