Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Facebook SDK

Discussion in 'General Discussion' started by JesOb, Jul 23, 2013.

  1. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,106
  2. cCoding

    cCoding

    Joined:
    Jul 3, 2012
    Posts:
    118
    Ah, I forgot all about this! I too would like to know where the c# SDK is.
     
  3. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    I am really interested too! ...especially on this: "Facebook is currently deploying a new Web Player install flow...".

    Any news about this?
     
  4. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    We're currently running closed tests with Facebook in order to fix bugs and improve the API, that's latest at the moment.
     
  5. Ziboo

    Ziboo

    Joined:
    Aug 30, 2011
    Posts:
    356
    A very neat feature I would like to see, is a way to publish a unity player on the wall directly !
     
  6. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,106
    Tanks :)
     
  7. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    282
    Thanks for keep us updated.
    With that new Facebook SDK, Could we use the "Requests Dialog" and "Facebook Login" in the Standalone builds?
     
  8. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Thanks this is a great news!
     
  9. Forge Vault

    Forge Vault

    Joined:
    Feb 18, 2012
    Posts:
    214
    Does anybody know if there are limitations beyond the standard pc/Mac requirements for deploying a game that runs off a Facebook page?
     
  10. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106

    I'm not sure what the features and guts will be yet, so I can't give you an update on that.
     
  11. Forge Vault

    Forge Vault

    Joined:
    Feb 18, 2012
    Posts:
    214
    Thanks for the heads up.
     
  12. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Unity facebook sdk is pretty great, but...


    Does anyone know how to post a screenshot in facebook? This would seem pretty basic and several plugins have this functionality, but the FB.API does not seem to allow for passing the image data as multipart which is what facebook wants.
     
  13. PetarMihajlovic

    PetarMihajlovic

    Joined:
    Mar 20, 2013
    Posts:
    2
    my function look like this:
    IEnumerator TakeScreenShot() // coroutine because I want to wait until end of frame
    {
    yield return new WaitForEndOfFrame();
    Texture2D tex = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24, false);
    tex.ReadPixels(new Rect(0,0,Screen.width,Screen.height),0,0);
    tex.Apply();
    byte[] buffer = tex.EncodeToPNG();
    // System.IO.File.WriteAllBytes(Application.dataPath + "/screenshots/screen/MyShot" + ".png", buffer);

    // From byte array to string
    string s = Convert.ToBase64String(buffer);// maybe this is not corect compression
    var query = new Dictionary<string, string>();
    query["photos"] = s;//Instance.score.ToString();
    FB.API("me?fields=photos",Facebook.HttpMethod.POST, delegate (string r) { ; }, query);
    }
    Wnen I go to FB GraphExplorer and call me?fields=photos I get only my ID and field "photos" on the left is whiter then the other fields.
    I have granted user_photos checkbox in permissions. I think for screenshots we must use FB.API because FB.Feed field picture must be on http.
    Eclipse dont show any errors so I belive error is somewhere in permissions. If I find solution I will post
     
  14. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    Code tags please!
     
  15. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Hey Aurore, what would be the best way to reach Facebook devs to query about this issue? In not clear from the facebook unity sdk page.
     
  16. brian_jew

    brian_jew

    Joined:
    Sep 19, 2013
    Posts:
    5
    You can do a WWW class with graph.facebook.com. Pass in the texture.EncodeToPNG() as a binary data with key name "picture" to WWWForm.

    see: https://developers.facebook.com/docs/reference/api/photo/
     
  17. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766

    Thank you Brian, that did the trick. For anyone who has that issue, here is the code I am using:

    Code (csharp):
    1.  
    2. private IEnumerator<WWW> PostPictureToFacebook(string caption, byte [] bytes)  
    3. {
    4.     // Create a Web Form
    5.     var form = new WWWForm();
    6.     form.AddField("message", caption);
    7.     form.AddBinaryData("source", bytes, "screenShot.png", "image/png");
    8.        
    9.     string url = "https://graph.facebook.com/me/photos?access_token="  + FB.AccessToken;
    10.        
    11.     var w = new  WWW(url, form);
    12.        
    13.     yield return w;
    14.        
    15.     if (string.IsNullOrEmpty(w.error))
    16.     {
    17.         Debug.Log("Picture posted to facebook");
    18.     } else {
    19.         Debug.LogError(w.error);
    20.     }
    21. }
    22.  
    23.  
     
    Last edited: Sep 20, 2013
  18. DaMex

    DaMex

    Joined:
    Jul 12, 2012
    Posts:
    21
    Hi everyone, hope I m not in the wrong spot of the forum for this issue !
    Any ways, I got an issue to set up the latest version of the Unity Facebook SDK released, the 4.2.1
    (build version 130912.80d74183e6e5bd9)

    The problem that I m blocked at the app config step, following the documentation on facebook developer pages, it says that the SDK should be printing up the Key Hash for my app so I just have to copy / paste it the the facebook app config edition. But actually the Facebook Settings tool in Unity doesn't show up any key hash (nothing appears in front of Debug Android Key Hash), the app name and app ID are there, as much as the package and class name !

    I have a feeling that I m missing something stupid out there but after 3 hours trying to find any hint somewhere, ... I m just stucked.

    Any help please ?
     
  19. cubaschi

    cubaschi

    Joined:
    Oct 23, 2012
    Posts:
    51
    Hi,
    We are using the latest 4.2.1 SDK version and are still having a problem with the login. We always get a "app is in sandbox mode" event though it isn't for sure. Has anyone experienced the same problems?

    Simon
     
  20. DaMex

    DaMex

    Joined:
    Jul 12, 2012
    Posts:
    21
  21. Asif-khan922

    Asif-khan922

    Joined:
    Aug 27, 2013
    Posts:
    1
    hi friends
    I am facing an issue in my Facebook game in unity. Game is on web facebook. it loads and game is ready i can play in single mode but when i try to send a challenge to my friend, he received my challenge request but once he accept the request an automatic page comeup with this error "Sorry, this page isn't available "
    Can any one help me please.
     
  22. Ferryun

    Ferryun

    Joined:
    Dec 10, 2013
    Posts:
    2
    Hi friends, Would you give me a demo about facebook SDK, I want to Login and Upload some phote in my Desktop App.Thanks.
     
  23. Ferryun

    Ferryun

    Joined:
    Dec 10, 2013
    Posts:
    2


    Hi goldbug, Would you give me a demo about facebook SDK, I also want to login and post some screenshot to facebook in my Desktop App(C#).Thanks.
    My Email:Ferryun@gmail.com
     
  24. Gonjes

    Gonjes

    Joined:
    Jul 10, 2013
    Posts:
    14
    I tested that code then i found out photo that i upload was in my photos at facebook.
    What i want is to post photo at my timeline or newsfeed but i don't know how to..
    can you help me please?
    :confused:
     
  25. goldbug

    goldbug

    Joined:
    Oct 12, 2011
    Posts:
    766
    Forget that code. I pinged facebook about the gap in their api not supporting binary data, and shortly after they added the ability to use WWWForm in their api specifically so that one can post pictures and other binary data.

    documentation is available right here:
    https://developers.facebook.com/docs/unity/reference/current/FB.API
    with example code.

    I don't know how to post to the user's profile, but if you find out, do let us know please
     
  26. Gonjes

    Gonjes

    Joined:
    Jul 10, 2013
    Posts:
    14
    Thanks for info, but i think what you want to know was like what i want to find out...
    if post picture to photos section at facebook, it posted succesfully.
    i keep searching on how to post image/picture to timeline(at newsfeed) as status like what you want to post to user's profile
     
  27. Gonjes

    Gonjes

    Joined:
    Jul 10, 2013
    Posts:
    14
    @goldbug
    finally i succeed post image and message to own facebook wall.
    that image that successful uploaded to the wall will be automatic in image album(photos).

    IEnumerator PostPictureToFacebook(string caption, byte[] bytes)
    {
    yield return new WaitForEndOfFrame();

    var wwwForm = new WWWForm();
    wwwForm.AddField("message", caption);
    wwwForm.AddBinaryData("image", bytes, "image.png");

    FB.API("me/photos", Facebook.HttpMethod.POST, Callback, wwwForm);
    }
     
    goldbug likes this.
  28. EddieChristian

    EddieChristian

    Joined:
    Oct 9, 2012
    Posts:
    725
    I am setting up an android app for Facebook tonight. I noticed that we have to put in a Debug Android Keyhash. Is there a Release Keyhash that I need to generate as well? And if so how do I do this???
     
  29. DannyDan2468

    DannyDan2468

    Joined:
    Feb 23, 2014
    Posts:
    9
    Hi,

    I'm facing the exact same problem but with an Android app. Anyone solved this issue and can point me in the right direction what I'm missing here?

    Edit: OK, it seems that it now works when I'm using the Facebook app for Android. When I click on the request, the play store opens up with. This is exactly what I want. But when clicking on the request from within the webbrowser, it still doesnt find the page. :-(

    Edit2: Problem solved!
    So if anyone has the same issue: You need to get your App approved by Facebook. After that, the links are working fine!

     
    Last edited: Apr 9, 2014
  30. BraveVN

    BraveVN

    Joined:
    Jun 12, 2013
    Posts:
    21
    sorry to dig this topic out, but can you guide me how to call this function ?
    I use this function when I hit the button and which variables should I use for *byte[] bytes* ?
    thanks.

    Code (csharp):
    1. void callFB () {
    2.         if (!FB.IsLoggedIn) {
    3.             FB.Login("email,publish_actions", LoginCallback);                                                                                                                                                                
    4.         }
    5.         else StartCoroutine(PostPictureToFacebook("test caption", byte[] bytes));
    6.     }
     
  31. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
    BraveVN: latest Facebook SDK has screenshot sending example in InteractiveConsole scene
     
  32. BraveVN

    BraveVN

    Joined:
    Jun 12, 2013
    Posts:
    21
    I just copied the code in the InteractiveConsole but it's still not work :( can you help me ?
     
  33. dttngan91

    dttngan91

    Joined:
    Nov 21, 2013
    Posts:
    80
    Yes, I did FB.API me/photos just like FB example but has been denied by FB review team by the following reason:
    Your app's users must enter all content in the user message field. Don't auto-populate the message field with any content, including links and hashtags, even if you allow users to edit the content before sharing. Watch this informational video for more information, and seePlatform Policy 2.3

    Is there any suggestion how post a screenshot as well as allow user explicit write their message? :(
     
  34. norbertots

    norbertots

    Joined:
    Jul 4, 2014
    Posts:
    15
    i need a solution to send a picture to a facebook fan page in Unity3d standalone or web build in Windows 7? any examples with source code ? please help ..
     
  35. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Why does not facebook sdk support desktop app?