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

  • reddalek

    (@reddalek)


    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)
  • reddalek

    (@reddalek)

    @aljawalat After I made the change, I still had some error messages on the admin screen which I cleared using the ‘Clear all error messages’ option under ‘Misc.’. If you do that, do the error messages reoccur? Have you tested the plugin functionality itself?

    aljawalat

    (@aljawalat)

    @reddalek
    I cleared using the ‘Clear all error messages’ option under ‘Misc.’.
    its oky

    but no link in my facebook page why ?
    i mean i write new article but plugin dont put link to my page as it worked before.

    reddalek

    (@reddalek)

    @aljawalat

    Possible for you to share your add-link-to-facebook-int.php file?

    spiritfly

    (@spiritfly)

    Awesome find man! I thought something if off with the plugin, but didn’t know what.. Works wonderfully well!

    karnerkreativ

    (@karnerkreativ)

    After clearing all errors your fix works. Thanks!

    aljawalat

    (@aljawalat)

    thank you @reddalek
    now works. Thanks!

    dregad

    (@dregad)

    Thanks for the tip !

    nulldogmas

    (@nulldogmas)

    Worked for me as well, thanks so much, @reddalek!

    Gary Pardun

    (@garypardun)

    That fixed it for me. Thanks!

    Super fix @reddalek. Updated the file, reauthorized, cleared error messages and everything works as usually. Hope this will get fixed in the plugin itself soon.

    aljawalat

    (@aljawalat)

    Thank you reddalek.

    danwolfeus

    (@danwolfeus)

    A thousand thanks for this fix! Worked like a charm!

    Dan

    Patrick.Tingen

    (@patricktingen)

    @reddalek Thanks for this fix. I did as you advised and got it working again within 5 minutes!

    zxen

    (@zxen)

    Thanks so much!

    fuzzybo

    (@fuzzybo)

    Thank you for your fix! Perhaps the author can include it ASAP.

Viewing 15 replies - 16 through 30 (of 64 total)
  • You must be logged in to reply to this topic.