Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
953 views
in Q2A Core by
The facebook login isn't working and isn't working on your site either!
Q2A version: 1.7x
by
facing the same issue ..noticed today
by
Can everyone who's having the same problem visit the github issue and "heart" it, hopefully this will give priority. Thank you

https://github.com/q2a/question2answer/issues/510
by
Look what I found - https://github.com/mouneyrac/moodle-auth_googleoauth2/issues/231

Apparently Facebook API 2.2 stopped being supported on the 27th of March... Hm!

Will "heart" it on github. Must be fixed a.s.a.p.!
by
I'm on DreamHost's VPS. And they had a system update yesterday. I submitted a ticket... but it seems that it was just a coincidence. Will "heart" it on github. Must be fixed!

2 Answers

+1 vote
by
Bug is already filed, we will check.

https://github.com/q2a/question2answer/issues/510
by
Thank you! From my 3 hours of digging yesterday it seems to be that something on the facebook oAuth has been updated requiring an update in the code. Although I'd consider myself an intermediate php coder, I'm not yet familiar enough with how classes and functions are called in question2a core, but usually with my experience stuff like this is a stupid 1 or 2 line fix or a variable throwing something off.
+2 votes
by
edited by

This fixed for me, as suggested by valan on github https://github.com/q2a/question2answer/issues/510#issuecomment-289858537 per this http://stackoverflow.com/questions/42994019/facebook-graph-api-not-work-from-2-2-to-2-3

USE AT YOUR OWN RISK. NOT TO BE USED ON PRODUCTION SITES.

In qa-plugin/facebook-plugin/base_facebook.php

/*  FIND THIS  */

    $response_params = array();
    parse_str($access_token_response, $response_params);

    if (!isset($response_params['access_token'])) {
      return false;
    }

    $this->destroySession();

    $this->setPersistentData(
      'access_token', $response_params['access_token']
    );


/* TO BE REPLACED WITH THIS */
    $response = json_decode($access_token_response);
    if (!isset($response->access_token)) {
      return false;
    }

    $this->destroySession();

    $this->setPersistentData(
      'access_token', $response->access_token
    );


/* FIND THIS */

    $response_params = array();
    parse_str($access_token_response, $response_params);
    if (!isset($response_params['access_token'])) {
      return false;
    }

    return $response_params['access_token'];

/* REPLACE WITH THIS */

    $response = json_decode($access_token_response);
    if (!isset($response->access_token)) {
      return false;
    }
    return $response->access_token;


by
For those who are not code savvy, I've compiled the new php file that should replace.

/public_html/qa-plugin/facebook-login/base_facebook.php

Simply delete or rename original and replace with this new file.

NOTE**** GitHub only allows .txt files to be uploaded so just rename to .php.

The credit for this fix should be given to @Dan_D. I'm waiting to hear back on whether there are any security issues that would cause this to not be used on a "Production Site" or if he simply doesn't want blame for people copying and pasting the wrong code and therefore screwing something up. ;-)

I have verified this to work though.

GitHub Download Link: https://github.com/q2a/question2answer/files/879387/base_facebook.txt
by
Is there a security reason your saying not to use this on a production site? Or is simply because this "might" mess something up? THANK YOU FOR THE ANSWER!
by
If there is no security issue this solution is perfect! Thank you!
by
I am not too familiar with the original plugin. I just wanted to help with this issue. So, I scanned the code and made a few adjustments. There's a chance that I might have missed a thing or two, which should be tweaked, considering the new FB API. Perhaps the original developers can take a look and polish things up.
by
In case anyone needs, they can use
https://github.com/arjunsuresh/q2a-open-login
...