Support » Plugin: Add Link to Facebook » Fix for ‘Facebook error: Invalid OAuth access token’ error with API v2.3

  • Hi,

    Today Facebook ended support for v2.2 of the API, and v2.3 includes a change to the format of access tokens which broke the ‘Add Link to Facebook’ plugin and generates the access token error above.

    After a little debugging, I found a fix by editing the add-link-to-facebook-int.php file:

    Replace

    static function Process_fb_token($response) {
    	$key = 'access_token=';
     	$access_token = substr($response, strpos($response, $key) + strlen($key));
    	$access_token = explode('&', $access_token);
    	$access_token = $access_token[0];
    	return $access_token;
    }
    

    with

    static function Process_fb_token($response) {
    	$key = 'access_token=';
    	$access_token = json_decode($response)->access_token;
    //	$access_token = substr($response, strpos($response, $key) + strlen($key));
    //	$access_token = explode('&', $access_token);
    //	$access_token = $access_token[0];
    	return $access_token;
    }
    
Viewing 15 replies - 16 through 30 (of 64 total)
Viewing 15 replies - 16 through 30 (of 64 total)
  • You must be logged in to reply to this topic.