Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

facebook login stopped working, It's not even working on your site!

+4 votes
522 views
asked Mar 27 in Q2A Core by Upset
The facebook login isn't working and isn't working on your site either!
Q2A version: 1.7x
commented Mar 28 by Dan D
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.!
commented Mar 28 by Dan D
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
answered Mar 28 by ProThoughts
Bug is already filed, we will check.

https://github.com/q2a/question2answer/issues/510
commented Mar 28 by cksagherian
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
answered Mar 28 by Dan D
edited Mar 29 by Dan D

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;


commented Mar 29 by Dan D
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.
commented May 11 by Arjun Suresh
In case anyone needs, they can use
https://github.com/arjunsuresh/q2a-open-login
...