Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

Facebook plugin problem

Hello,

I've got a problem with the Facebook plugin on Vanilla 2.3.1

I can't use it anymore but nothing has change on my forum.

Here is the error:

file_get_contents(https://graph.facebook.com/me?access_token=&fields=name,id,email): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request

0 [internal function]: Gdn_ErrorHandler(2, 'file_get_conten...', '/home/gghfmftq/...', 611, Array)

1 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(611): file_get_contents('https://graph.f...')

2 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(510): FacebookPlugin->getProfile(false)

3 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(873): FacebookPlugin->base_connectData_handler(Object(EntryController), Array, 'base_connectdat...')

4 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(786): Gdn_PluginManager->callEventHandler(Object(EntryController), 'Base', 'ConnectData', 'Handler')

5 /home/gghfmftq/www/vanilla/library/core/class.pluggable.php(133): Gdn_PluginManager->callEventHandlers(Object(EntryController), 'EntryController', 'ConnectData')

6 /home/gghfmftq/www/vanilla/applications/dashboard/controllers/class.entrycontroller.php(417): Gdn_Pluggable->fireEvent('ConnectData')

7 [internal function]: EntryController->connect('facebook')

8 /home/gghfmftq/www/vanilla/library/core/class.dispatcher.php(326): call_user_func_array(Array, Array)

9 /home/gghfmftq/www/vanilla/index.php(44): Gdn_Dispatcher->dispatch()

10

Thanks for the help ;)

Comments

  • Could you try redownloading 2.3.1, and replacing the "plugins/Facebook" folder of your website with a fresh version from the 2.3.1 zip?

    Could you also try disabling other plugins to see if the problem persists?

    And when do you get this error? What're you trying to do? A.k.a. do you get this error when you try to login to your forum or at some other time?

  • Thanks for your help.

    I've uploaded a fresh 2.3.1 version with facebook plugin.
    But the problem persists.

    Error appears when you click on login with Facebook. => you put your login and pass => error message

  • As far as I can tell, there's a catch clause that's not catching an exception like it should.

    On line 511, it's trying to request profile data from Facebook, and since it doesn't have an access token yet it makes a bad request.

    That should be caught on line 512, which should prompt a Facebook login screen.
    But that exception doesn't get caught for some reason and I'm not familiar enough with php to recognize why.

    Which PHP version are you using?

    You could try changing line 512 "catch (Exception $Ex) {" to "catch (\Exception $Ex) {" as per this thread to see if it helps.

    https://stackoverflow.com/questions/2172715/try-catch-block-in-php-not-catching-exception

  • It's a 5.6 php version.

    I've changed the line 512 without success.

    It strange because problem appears without changing anything. Last week was ok, yesterday no more ...

  • Could you add:

    if(!$AccessToken)
    {
           throw new Exception('No access token.');
    }
    

    On line 604? (After "public function getProfile($AccessToken) {")

  • Hello,

    I've added like this:

    public function getProfile($AccessToken) {
    if(!$AccessToken)
    {
    throw new Exception('No access token.');
    }
    $Url = "https://graph.facebook.com/me?access_token=$AccessToken&fields=name,id,email";
    // $C = curl_init();
    // curl_setopt($C, CURLOPT_RETURNTRANSFER, true);
    // curl_setopt($C, CURLOPT_SSL_VERIFYPEER, false);
    // curl_setopt($C, CURLOPT_URL, $Url);
    // $Contents = curl_exec($C);
    // $Contents = ProxyRequest($Url);
    $Contents = file_get_contents($Url);
    $Profile = json_decode($Contents, true);
    return $Profile;
    }

    But return error :

    Undefined variable: Profile

    0 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(527): Gdn_ErrorHandler(8, 'Undefined varia...', '/home/gghfmftq/...', 527, Array)

    1 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(873): FacebookPlugin->base_connectData_handler(Object(EntryController), Array, 'base_connectdat...')

    2 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(786): Gdn_PluginManager->callEventHandler(Object(EntryController), 'Base', 'ConnectData', 'Handler')

    3 /home/gghfmftq/www/vanilla/library/core/class.pluggable.php(133): Gdn_PluginManager->callEventHandlers(Object(EntryController), 'EntryController', 'ConnectData')

    4 /home/gghfmftq/www/vanilla/applications/dashboard/controllers/class.entrycontroller.php(417): Gdn_Pluggable->fireEvent('ConnectData')

    5 [internal function]: EntryController->connect('facebook')

    6 /home/gghfmftq/www/vanilla/library/core/class.dispatcher.php(326): call_user_func_array(Array, Array)

    7 /home/gghfmftq/www/vanilla/index.php(44): Gdn_Dispatcher->dispatch()

    8

    Undefined variable: Profile

    0 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(531): Gdn_ErrorHandler(8, 'Undefined varia...', '/home/gghfmftq/...', 531, Array)

    1 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(873): FacebookPlugin->base_connectData_handler(Object(EntryController), Array, 'base_connectdat...')

    2 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(786): Gdn_PluginManager->callEventHandler(Object(EntryController), 'Base', 'ConnectData', 'Handler')

    3 /home/gghfmftq/www/vanilla/library/core/class.pluggable.php(133): Gdn_PluginManager->callEventHandlers(Object(EntryController), 'EntryController', 'ConnectData')

    4 /home/gghfmftq/www/vanilla/applications/dashboard/controllers/class.entrycontroller.php(417): Gdn_Pluggable->fireEvent('ConnectData')

    5 [internal function]: EntryController->connect('facebook')

    6 /home/gghfmftq/www/vanilla/library/core/class.dispatcher.php(326): call_user_func_array(Array, Array)

    7 /home/gghfmftq/www/vanilla/index.php(44): Gdn_Dispatcher->dispatch()

    8

    Undefined variable: Profile

    0 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(532): Gdn_ErrorHandler(8, 'Undefined varia...', '/home/gghfmftq/...', 532, Array)

    1 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(873): FacebookPlugin->base_connectData_handler(Object(EntryController), Array, 'base_connectdat...')

    2 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(786): Gdn_PluginManager->callEventHandler(Object(EntryController), 'Base', 'ConnectData', 'Handler')

    3 /home/gghfmftq/www/vanilla/library/core/class.pluggable.php(133): Gdn_PluginManager->callEventHandlers(Object(EntryController), 'EntryController', 'ConnectData')

    4 /home/gghfmftq/www/vanilla/applications/dashboard/controllers/class.entrycontroller.php(417): Gdn_Pluggable->fireEvent('ConnectData')

    5 [internal function]: EntryController->connect('facebook')

    6 /home/gghfmftq/www/vanilla/library/core/class.dispatcher.php(326): call_user_func_array(Array, Array)

    7 /home/gghfmftq/www/vanilla/index.php(44): Gdn_Dispatcher->dispatch()

    8

    Undefined variable: Profile

    0 /home/gghfmftq/www/vanilla/plugins/Facebook/class.facebook.plugin.php(537): Gdn_ErrorHandler(8, 'Undefined varia...', '/home/gghfmftq/...', 537, Array)

    1 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(873): FacebookPlugin->base_connectData_handler(Object(EntryController), Array, 'base_connectdat...')

    2 /home/gghfmftq/www/vanilla/library/core/class.pluginmanager.php(786): Gdn_PluginManager->callEventHandler(Object(EntryController), 'Base', 'ConnectData', 'Handler')

    3 /home/gghfmftq/www/vanilla/library/core/class.pluggable.php(133): Gdn_PluginManager->callEventHandlers(Object(EntryController), 'EntryController', 'ConnectData')

    4 /home/gghfmftq/www/vanilla/applications/dashboard/controllers/class.entrycontroller.php(417): Gdn_Pluggable->fireEvent('ConnectData')

    5 [internal function]: EntryController->connect('facebook')

    6 /home/gghfmftq/www/vanilla/library/core/class.dispatcher.php(326): call_user_func_array(Array, Array)

    7 /home/gghfmftq/www/vanilla/index.php(44): Gdn_Dispatcher->dispatch()

    8

  • Sorry man, bit out of ideas :(

    So the problem is that you don't get an access_token between lines 497 - 510. I'm not familiar enough with the code to make a guess why that is.

    I would replace class.facebook.plugin.php with a fresh one just to make sure you reverted the changes I suggested.

    Less-than-ideal solution, but I thought I'd mention it:

    You could switch to this plugin:
    https://open.vanillaforums.com/addon/1556/oneall-social-login

    You have to add 5 lines and change two lines to get it to work with Vanilla 2.3.1 properly though:
    https://github.com/oneall/social-login-vanilla-forum/pull/6/files

    Here's some documentation to get it to work:

    https://docs.oneall.com/plugins/guide/social-login-vanilla/

    Fair warning about the disadvantages:

    • Not official Vanilla material
    • You have to create an oneall account, and add api settings there
    • People probably have to jump through some hoops (request an actual password if they only ever logged in via facebook to your forum, login with password, connect their profile to Facebook via OneAll) to be able to login via Facebook again.

    Advantages:

    • It might work, and then you don't have to spend hours debugging an obscure bug.
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    There were some problems with the facebook plugin. Could you check if changing "javascript" to "json" helps like it is done here:

    https://github.com/vanilla/vanilla/commit/24ee09ab348b88f89737da4e976399835925f854#diff-fa8689b808080a1456afb013beefca68

    Caylus
  • Last post from R_J solve the problem ;)

    Thanks a lot for help

    R_JCaylus
Sign In or Register to comment.