Hybridauth - PHP - Facebook returned an invalid user id

浪子不回头ぞ 提交于 2019-11-28 13:24:35

I had a similar problem and I believe in my case I found the solution and maybe it would help someone else. (CURLOPT_CONNECTTIMEOUT)

HybridAuth error (invalid user) is very generic, basically it looks if the curl returns something and if not, gives that error, but the real reason is not visible in the error message.

What I ended up doing is downloading the facebook php sdk and using the default example https://github.com/facebook/facebook-php-sdk/blob/master/examples/example.php

(Changed the keys to my app)

At that point I was able to see new error messages that were not showing before when using HybridAuth

PHP Fatal error: Uncaught CurlException: 6: name lookup timed out

That pointed me to this article http://milkcodes.blogspot.com/2010/12/php-fatal-error-uncaught-curlexception.html that talks about increasing the timeout of CURL in base_facebook.php which I did and Voila! started working again.

The underlying issue in many posts is that CURL connectivity is mostly responsible for these issues (https, timeout, nslookup, etc..)

A good way to quickly figure it out is by keeping a test script with fb sdk handy for debugging.

in base_facebook.php around line 133

public static $CURL_OPTS = array(
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 60,
    CURLOPT_USERAGENT      => 'facebook-php-3.2',

Maybe your configuration sends KEY instead of ID:

Facebook Example:

"keys"    => array ( "id" => "PUT_YOURS_HERE", "secret" => "PUT_YOURS_HERE" )

Twitter Example:

"keys"    => array ( "key" => "PUT_YOURS_HERE", "secret" => "PUT_YOURS_HERE" )

It is due to api change of facebook graph api, you can download latest version of Hybridauth for facebook https://github.com/hybridauth/hybridauth, currently third party api is not available for facebook so you need to download facebook sdk and place it under thirdparty directory, you can download it from https://github.com/facebook/php-graph-sdk.

After downloading you may need to configure facebook sdk auto-load files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!