My dilemma with loading online image from facebook

Good Day Humble Folks.
So in my current project i am doing, i ran into a problem on the android side. I am implementing facebook with my game, but the thing is that, when i load a image from the facebook the app crash at times and that isn’t good. I already read that it is a problem with the way cocos handle loading images from online and that a it is being looked at.
The thing is I really want to release the game new year’s eve. So i am asking if there is any other to do this in cocos2d-js without the side effects it have on android.

P.S i don’t know if iphone have this problem as well, since i don’t have one to test on.

Can you describe how to reproduce the error, and what’s the error message, and other informations you feel helpful for others to understand better the problem

I have this problem as well, it’s driving me nuts (both on Android and iOS).
My code for example is:

function FBgetPicture ( userid, target, cb ) {

    FBInstance.api("/" + userid + "/picture", plugin.FacebookAgent.HttpMethod.GET,
        {"type" : "normal", "height" : 80, "width" : 80}, function (type, response) {
        if (type == plugin.FacebookAgent.CODE_SUCCEED) {
            console.log("FBgetPicture: " + JSON.stringify(response));
            cc.loader.loadImg(response.data.url, function () { cb.call(target, userid, response.data.url)});
        } else {
            console.log("FBgetPicture: Graph API request failed, error #" + type + ": " + JSON.stringify(response));
        }
    });
}

in iOS I get:

“error_message”:"Error Domain=com.facebook.sdk Code=6 “Response is a non-text MIME type; endpoints that return images and other binary data should be fetched using NSURLRequest and NSURLConnection” UserInfo=0x7fdd10522dd0 {com.facebook.sdk:HTTPStatusCode=0, NSLocalizedDescription=Response is a non-text MIME type; endpoints that return images and other binary data should be fetched using NSURLRequest and NSURLConnection

on Android the error messages changes from time to time (Fatal error, SIGSEGV, etc…)
I’m looking for a good example for a generic code which will work good on both platforms.
Thanks.

Hi,@shirkan

I believe it’s a bug in Facebook integration, we treat all response in the same way which is to wrap it into a json string. I think the error message indicate that we shouldn’t do it that way.

I have created an issue: https://github.com/cocos2d/cocos2d-js/issues/1226

As for now, please avoid using this kind of graph APIs

Thanks for taking care of it.
So, it’s not possible right now to show facebook profile pictures on ios and android?
How about downloading the photo from the link, as if it was a photo from the web (and not facebook specific, that is)?

I think their are two ways

  1. Use http graph API address to retrieve the photo. But I’m not sure how to parse the result in native platform
  2. Use their PHP sdk to retrieve the photo with your server, then get the photo from your server.

Can you write a short code explanation for #1?
Regarding #2 - when i run the game locally on web, it starts a local server but when running on ios & android i believe it doesn’t open such a server, correct? If so, how can i overcome this probelm? If i’m wrong, can you write a short pseudo code to demo how to do it?

Thanks