3

I am trying to integrate facebook sdk in my unity android game. I can not find FBUtil and GameStateManager in SDK downloaded from developer site. I got the userId using FB.UserId. Also got the response

"sending to Unity OnInitComplete({"access_token":"CAAUCMHNGlZCcBAHJBQAs7AoJNevkZAFbkpSRk60TURemvv4Y6IOu9NXjGcFjFRZAx9RoxwKT4ZBZASs0NLiYTmi4rl7RyWYdtxxhlKkSjoIWiqqDSBdSDKk0OppB2ZB4U6IgtqQs9PM8uNCaNF5xgqWn2c9DDkp4dJc9p38XONKpdwRF7qDHtM","user_id":"100003735696788","opened":true})"

Just after that when I tried to get profile picture of the user, using the code given on developer.facebook.com,

void LoginCallback() {
FB.API (
    "/me/picture",
    Facebook.HttpMethod.GET,
    APICallback
);      

}

The response I get is 4 question marks.

????

where is the problem? Please help..

Nick
  • 1,035
  • 1
  • 11
  • 18
  • The problem of `FileNotFoundException` has been resolved. Now waiting for response from FB regarding missing classes FBUtil and GameStateManager. – Nick Sep 02 '13 at 09:09
  • Hi Nick, Can you tell me which code snippet referenced these? In the meantime here are the files: http://snipplr.com/view/72268/gamestatemanagercs/ http://snipplr.com/view/72269/fbutilcs/ Thanks for checking out the SDK! – aaron Sep 03 '13 at 05:13
  • 1
    Hi @aaron, thanx for the reply. The issue I was facing in getting profile pic has been resolved by using hardcoded link `http://graph.facebook.com/"+FB.UserId.ToString()+"/picture?type=large` since I am not getting right response from FB using this link https://developers.facebook.com/docs/unity/reference/FB.API/. The link you provided for the gamestatemanager and fbutil gives error `"The snippet you're looking for has either been deleted by its owner or it never existed to begin with."` – Nick Sep 03 '13 at 11:58
  • 1
    I suspect that FBUtil and GameStateManager are classes included in the Friend Smash demo app. The docs where they are mentioned are in the Friend Smash tutorial https://developers.facebook.com/docs/unity/tutorials/games/personalize/ So just make your own versions of these classes if you need their functionality. – Donn Lee Sep 03 '13 at 22:05
  • 1
    @NickMascarenhas, those links should be public now (incognito window works for me, at least), sorry about that. The FB.API('/me/picture'...) should be supported but isn't, I'll make a task for that. Thanks for the feedback! – aaron Sep 04 '13 at 03:33
  • 2
    @aaron, Got it. I can see the code now. Thanks for the links. – Nick Sep 04 '13 at 04:34
  • 1
    Thank you @Aaron! This has been driving me nuts for 2 days trying to make the SDK work. I've been looking all over for the friend smash code referenced in the docs. The /me/... issues were making me crazy too. Thanks for being on top of this. – HowDoIDoComputer Sep 04 '13 at 16:39

2 Answers2

2

I used this link using WWW in Unity and it worked well.. This is exactly what I did

  1. Once you have the user id, create a WWW object like this:

WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture?type=large");

  1. Then in the LateUpdate I put an IF condition checking if the picture was loaded or not with a bool called loaded to avoid reloading the picture more than once

    if (url.isDone && !loaded)
    {
        loaded = true;            
    
        Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.ARGB32, false); //TextureFormat must be DXT5
    
        url.LoadImageIntoTexture(textFb2);
        PLANE_OR_QUAD_OBJECT.renderer.material.mainTexture = textFb2;
    
    }
    

NOTE: url is visible in the whole class as well as loaded

If you need further help with this, let me know!

Kennyomar
  • 107
  • 1
  • 7
  • I got the profile pic using this. Also when I call `FB.API ( "/me/picture", Facebook.HttpMethod.GET, APICallback );` I get response in delegate in undefined symbols like "???????" – Nick Aug 31 '13 at 10:26
1

Normally Facebook picture API should return data with Texture type NOT text

For example, If you use code like @jkgm777 answer,

WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture");

You should get Texture type that can use to replace your texture object in scene. But If you want to get image url, USE THIS

http://graph.facebook.com/INSERT_USER_ID_HERE/picture?redirect=false

You will get this JSON for response

data: {
url: "{#IMAGE_URL#}",
is_silhouette: false
}