Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API - Received Invalid JSON reply

We are using Facebook Graph API v2.9 to run "feed balancing" application: Like What You Hate

The app runs React served from a NodeJs server.

The app was running fine a few months ago (Dec. 2017) when we made some updates but we recently discovered that the app had stopped working.

Upon investigation I found that when I hit the following endpoints:

/me/picture?height=80&width=80
/me/picture
/{a-defined-user-id}/picture

graph api is returning the following error in the response:

{
    "error": {
        "code": 1,
        "error_subcode": 1357046,
        "message": "Received Invalid JSON reply.",
        "type": "http"
    }
}

Other endpoints, such as:

/me
/me/likes
/me/likes?limit=1000

return a JSON object as expected.

I've used the Graph API Explorer to hit the /me/picture endpoint and I get what seems to be a valid JSON response.

So it seems to be something with the SDK code. We are using the Javascript SDK and mounting it in our app thusly:

window.fbAsyncInit = function() {
    window.FB.init({
        appId            : fbAppId,
        xfbml            : true,
        version          : 'v2.9',
        cookie           : true
    });
    window.FB.AppEvents.logPageView();
};

(function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = '//connect.facebook.net/da_DK/sdk.js';
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

One thing to note is that we are getting the Danish SDK (da_DK) servers, but I have also tried the US version (en_US) and saw the same issue.

Edit: Just found that there is a recent Bug Report open for this issue.

like image 851
Barrett H. Avatar asked Aug 26 '26 11:08

Barrett H.


1 Answers

Was just able to resolve this issue by modifying the endpoint URL, per the latest on the bug report.

change: /{USER_ID}/picture

to: /{USER_ID}/picture?redirect=false

like image 83
Rachel Rine Avatar answered Aug 29 '26 14:08

Rachel Rine