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

[Closed] Social Networking Plugin (Facebook and Twitter) live!

Discussion in 'iOS and tvOS' started by prime31, Sep 19, 2010.

  1. Griffith

    Griffith

    Joined:
    Oct 19, 2011
    Posts:
    23
    Prime. Apologies for making you have to look that up. It seems if I do the request /1/friends/ids.json with no arguments, it will work after a restart or require authentication if there isn't a restart.

    To make this work fine, restart or not, it needs to be supplied with a screen name argument. Thanks for pointing me to the sample though that brought me to the bottom of the issue.

    Good plugin and support :)
     
  2. petero181

    petero181

    Joined:
    Feb 23, 2011
    Posts:
    104
    Hi Prime31, just update unity3D to 3.4.2 and ios sdk 5. Now there is no such red flag error. N I am trying your demo screen. Hope there is no any problem ... thx
     
  3. KDeriemaeker

    KDeriemaeker

    Joined:
    Nov 12, 2010
    Posts:
    17
    Hi guys,

    I am having a problem with the post-build step that adds the plugin code to the XCode project. We upgraded our dev machine to OSX Lion and XCode 4 a little while back, and now this doesn't seem to be working. Unity tells me Postprocessbuildplayer is being run, but I don't get a notification in Finder and XCode doesn't get the plugin code.

    Does the plugin build process support XCode 4, and if so how can I get this to work? Help would be much appreciated, thanks in advance.
     
  4. DarkJedi

    DarkJedi

    Joined:
    Apr 15, 2009
    Posts:
    48
    Hey KDeriemaeker - we upgraded a project with 4 Prime31 plugins from XCode 3 to 4, and they continue to work fine. :)

    I do remember some sort of hassle with XCode itself when we made the switch, I think I had to manually clear cached data from
    ~/Library/Developer/Xcode/DerivedData to properly build from scratch, but I forget the exact issue...

    Certainly you should delete any existing build folder and rebuild from scratch (and also "clean all targets" within XCode)

    Finally, does Unity have a "Prime31" menu? If so there's a "Plugin troubleshooter" option which will look for some basic common issues.
    For example, I have experienced the issue where the Postprocesbuildplayer scripts do not have execute permissions, and had to manually chmod +x them from terminal...

    HTH,
    Dan
     
  5. DarkJedi

    DarkJedi

    Joined:
    Apr 15, 2009
    Posts:
    48
    Hi Prime31, I have an iPhone 4 and iPad 2, both with iOS 5 (9A334).

    TwitterBinding.isTweetSheetSupported() always returns false on both devices even though TwitterBinding.canUserTweet() is true and I can happily post using TwitterBinding.showTweetComposer ...

    Is there something I'm doing wrong?
    Can I just use ~.canUserTweet() to determine an iOS 5 device with a valid Twitter account already bound to it?

    Many thanks once more!
     
  6. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @DarkJedi, that is very, very odd. I believe canUserTweet checks the same stuff as isTweetSheetSupported plus more. I would love to see that behavior in the debugger...if only I could reproduce.
     
  7. NT7Games

    NT7Games

    Joined:
    May 21, 2009
    Posts:
    43
    Hey Prime,

    I've integrated the SocialNetworking plugin, and verified that my user is logged in to facebook before retrieving their friends. I want to display the user's friends in a UI view along with their profile pictures. Here's the relevant code below:

    Code (csharp):
    1.     void facebookReceivedFriends( ArrayList result )
    2.     {
    3.         Debug.Log( "received total friends: " + result.Count );
    4.         for(int i = 0; i < result.Count; i++)
    5.         {
    6.             Hashtable ht = (Hashtable)result[i];
    7.             foreach(DictionaryEntry d in ht)
    8.             {
    9.                 string userID = ht["id"].ToString();
    10.                 string userName = ht["name"].ToString();
    11.                
    12.                 Debug.Log(userID + "," + userName);
    13.                
    14.                 FacebookBinding.graphRequest(userID + "/picture", "GET", new Hashtable());
    15.             }
    16.         }
    17.     }
    I can confirm that

    a) userID has the friend's userID
    b) userName is accurate

    My problem is that the callback to facebookDidRecieveCustomRequest(string result) returns an empty string!

    Code (csharp):
    1.     public void facebookDidReceiveCustomRequest( string result )
    2.     {
    3.         Debug.Log(result);
    4.         if( facebookReceivedCustomRequest != null )
    5.         {
    6.             object obj = MiniJSON.jsonDecode( result );
    7.             facebookReceivedCustomRequest( obj );
    8.         }
    9.     }
    so, in the above example, result is NOT null but appears to be ""... This will create an object from an empty string which I believe makes the object null. I'm actually seeing a NullReferenceException when I try to access obj from within facebookRecievedCustomRequest(object obj).

    So I guess my question is if I'm formatting my graph request properly, because that is likely the source of the issue since others are successfully using the plugin :)

    Thanks for the help!
     
  8. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @NT7, your request looks fine but your event handler is the issue. The custom request returns an object, not a string. The object will be either an ArrayList or a Hashtable. You can check by just doing something like the following:

    var ht = result as Hashtable;
    If( ht != null )
    Use the ht

    var list = result as ArrayList;
    if( list != null )
    Use the list
     
  9. NT7Games

    NT7Games

    Joined:
    May 21, 2009
    Posts:
    43
    OK, assuming my request is well-formatted, then there is something else going on. In the following function:

    Code (csharp):
    1. public void facebookDidReceiveCustomRequest( string result )
    2. {
    3.     Debug.Log("recievedCustomRequest and it looks like: " + result + "!!!");
    4.     if( facebookReceivedCustomRequest != null )
    5.     {
    6.         object obj = MiniJSON.jsonDecode( result );
    7.         facebookReceivedCustomRequest( obj );
    8.     }
    9. }
    result is "" (an empty string). When this empty string gets put into obj from MiniJSON.jsonDecode(result), it is null. Therefore, when obj is passed to facebookRecievedCustomRequest, it is null and there is no data to work with:

    Code (csharp):
    1. void facebookReceivedCustomRequest( object obj )
    2. {
    3.     Hashtable ht = obj as Hashtable;
    4.     ArrayList al = obj as ArrayList;
    5.  
    6.     if( ht != null )
    7.     {
    8.         Debug.Log("It's a Hashtable");
    9.     }
    10.     else if( al != null )
    11.     {
    12.         Debug.Log("It's an ArrayList");
    13.     }
    14.     else if (obj == null)
    15.     {
    16.         Debug.Log("It's null");
    17.     }
    18.     else
    19.     {
    20.         Debug.Log(obj.GetType().ToString());
    21.     }
    22. }
    I will try other graph requests to see if I can get actual data back at all, as well. Any help is appreciated in the meantime!

    UPDATE 1: FacebookBinding.graphRequest("me","GET",new Hashtable()); returns exactly what I expect it to, so maybe it is in fact my request?
     
    Last edited: Nov 10, 2011
  10. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @NT7Games, setting up a result handler like the demos scene does (see below) is a great way to debug what Facebook is sending you. The ResultLogger class will let you debug the returned object by printing it all to the console.


    Code (csharp):
    1. // Sample of how to get the results of a custom facebook graph request
    2. SocialNetworkingManager.facebookReceivedCustomRequest += delegate( object result )
    3. {
    4.     ResultLogger.logObject( result );
    5. };
     
  11. pogoli

    pogoli

    Joined:
    May 30, 2008
    Posts:
    41
    Im trying to make use of a custom graphAPI call using the facebook social networking plugin but I am getting back unexpected and confusing data. Here's what's going on.

    Code (csharp):
    1. {
    2.   FacebookBinding.init("My App ID");
    3.   SocialNetworkingManager.facebookLogin += OnFacebookConnect;
    4.   FacebookBinding.login();
    5. }
    6.  
    7. public void OnFacebookConnect()
    8. {
    9.   SocialNetworkingManager.facebookLogin -= OnFacebookConnect;
    10.        
    11.   SocialNetworkingManager.facebookReceivedCustomRequest += OnFriendsLoad;
    12.  
    13.   FacebookBinding.graphRequest( "me/friends?fields=installed,first_name,last_name,picture", "GET", new Hashtable() );
    14. }
    15.  
    16. public void OnFriendsLoad(object result)
    17. {
    18.   SocialNetworkingManager.facebookReceivedCustomRequest -= OnFriendsLoad;
    19.   Debug.Log("OnFriendsLoad REACHED...  result below");
    20.   ResultLogger.logObject(result);
    21. }
    The result object that is logged is what I would get if I used just "me" as the graph api call. That is not what I expect to receive. Even here: https://developers.facebook.com/tools/explorer when I use:

    https://graph.facebook.com/me/friends?fields=installed,first_name,last_name,picture

    I get a list of my friends, not my own user information.

    Am I doing something wrong? How do I get the results I want?

    Thanks


    P.S. I'm using the latest version of the plugin (released 11/7), I'm not receiving any other errors amidst the output I am generating in the console output of xcode while running on a connected iPad.
     
  12. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @pagoli, I believe I responded to you via email already. Check your email.
     
  13. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Anyone else still seeing the "An error occurred with <game>. Please try again later." when trying to post to facebook? It seems to be some facebook error.
     
  14. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Doh, I forgot that I had changed my game to use showPostMessageDialogWithOptions, and was passing in the path to an image on the device, rather than a url, which fails (with a not very useful error). When I removed that it worked. I also discovered that you can no longer pre-fill the dialog with a message (as of July 12 according to https://developers.facebook.com/docs/reference/dialogs/feed/).
     
  15. Ben C

    Ben C

    Joined:
    Nov 15, 2011
    Posts:
    4
    Hello, this social networking plugin has been working great, except recently for trying to post tweets - the first time I posted a tweet via this plugin in a new app it worked, but all subsequent calls have failed to post a tweet. Then going back to a previous app (that used a version of this plugin from before the last couple of updates), I found that one no longer posts tweets too. Is this a known issue?
     
  16. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Ben, what error are you getting in the twitterPostFailed event? Are you by any chance trying to send the same tweet multiple times (Twitter will only let the first one go through).
     
  17. Ben C

    Ben C

    Joined:
    Nov 15, 2011
    Posts:
    4
    Aha! The error it returns is: Twitter post failed: Could not authenticate with OAuth.
    So the authentication is failing except for the first time? I have been using showOauthLoginDialog() for logging in to twitter each time.
    The tweets are definitely different each time.
     
  18. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Ben, so, you are logging in then posting a message and getting a "Could not authenticate with OAuth" error immediately? That seems quite odd. The OAuth token received from logging in should get you access to the Twitter API. What do you get returned when calling isLoggedIn? Are you sure you arent calling logout (which invalidates the access token) at some point?
     
  19. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    I find twitter to be a bit hit and miss. It works for one of my testers but only rarely for me :/
     
  20. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @sam, what error are you seeing? I haven't seen any issues recently with Twitter.
     
  21. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    I was getting "Could not authenticate with OAuth", but now it's started working again.. :/
     
  22. Ben C

    Ben C

    Joined:
    Nov 15, 2011
    Posts:
    4
    Yes, I log in - seemingly successfully - then get that error as soon as I post. isLoggedIn() is true every time I post, I have it check that function before calling postMessage(). And I'm not calling logout. It seems it should be working... perhaps something is wrong on Twitter's end?

    samizzo: it just started working again, without you making any changes?

    EDIT: Ok, same with me, it suddenly started working perfectly without me touching a thing! Before, I was logged out each time I started the app up and so was calling login each time. Now it keeps me logged in, and tweets go through without issue.
     
    Last edited: Nov 16, 2011
  23. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Ben and Sam, that definitely sounds like it was a hiccup on the Twitter side now that it has magically started working with no changes.
     
  24. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    Im trying to make a system in my app that will check if the user "liked" the app's page or didnt and give him a reward if he did. (facebook)

    im calling this graph request (After the user is already logged in to facebook)
    Code (csharp):
    1.  
    2. if(hit.transform.name == "btn_play_like") //check if user liked us
    3. {
    4.     FacebookBinding.init("114159058697229");
    5.     if(FacebookBinding.isLoggedIn())
    6.     {
    7.         Hashtable hash = new Hashtable();
    8.         hash.Add("access_token", FacebookBinding.getFacebookAccessToken());
    9.         string URL = "/me/likes";
    10.                 string Method = "GET";
    11.         FacebookBinding.graphRequest(URL,Method,hash);
    12.     }
    13. }
    14.  
    and in the recive data event i added a logger
    Code (csharp):
    1.  
    2. void facebookReceivedCustomRequest( object obj )
    3. {
    4.     ResultLogger.logObject(obj);
    5. }
    6.  
    but this always gets me empty data...
    here is the Xcode debugger results:

    Code (csharp):
    1.  
    2. btn_play_facebook
    3.  
    4. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhonePlayer-armv6/UnityEngineDebug.cpp Line: 34)
    5. [B]
    6. Successfully logged in to Facebook[/B]
    7.  
    8. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhonePlayer-armv6/UnityEngineDebug.cpp Line: 34)
    9.  
    10. [B]btn_play_like[/B]
    11.  
    12. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhonePlayer-armv6/UnityEngineDebug.cpp Line: 34)
    13.  
    14. [B]data: [/B]
    15.  
    16. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhonePlayer-armv6/UnityEngineDebug.cpp Line: 34)
    17.  
    18. [B]data: [/B]
    19.  
    20. (Filename: /Applications/buildAgent/work/842f9557127e852/Runtime/ExportGenerated/iPhonePlayer-armv6/UnityEngineDebug.cpp Line: 34)
    21.  
    22.  
    23.  
    what am i doing wrong?

    also i have another question,
    how can i open a facebook "page" within the application to allow the user to click the "like" button in it?
    (because i cant send a graph request forcing the place to "like" the page from within the app) i have to somehow open a facebook page focused on the like button.
     
  25. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @haimmaid, there is no need to send the access_token for Graph requests. The plugin will handle adding it for you. Are you sure you are adding the event listener for receiving the custom request event? A good test is to just include the *EventListener prefab which will listen to all the events for you and let you debug what is getting called.
     
  26. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    @prime[31] yes. im using the EventListener prefab and the event does trigger.
    but the result is as shown above
    "data:"
    "data:"
    just 2 empty "data:"s
    when im trying to GET just the "me" url i recive all my info there... but when i go for the "me/likes" url.. all i get is 2 empty "data:"s

    [edit]
    basically when im asking for the "me" url, it gives me exactly what i need
    when im asking for the "me/likes" url it returns a HashTable with 1 key - "data" and an ArrayList that it's Count property is 0 (an empty ArrayList) as a value for that key.
     
    Last edited: Nov 16, 2011
  27. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @haimaik, do you have permission to access that data? It could be that you need to ask for more specific permissions on login to get it.
     
  28. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    @prime31
    you mean something like this?
    Code (csharp):
    1.  
    2. string[] premissions = {"user_about_me","user_likes","user_birthday","user_checkins","user_online_presence"};
    3. FacebookBinding.loginWithRequestedPermissions(premissions);
    4.  
    edit:
    great, i guess the basic premissions are not enough to view my likes but with this login line it worked well.

    Thanks :)

    now i have another question. I can see that the unity app is able to open the Facebook app in order to log in.
    Is it possible to open it on a certain "page" so that the user will be able to click the "page"'s "like" button? (via the facebook app and if he doesnt have it installed via the safari?)
     
    Last edited: Nov 16, 2011
  29. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @haimmaik, the permissions look about right. Can you stick a breakpoint in the FacebookManager.mm file all the way down in the bottom method (application:handleOpenURL:) and print out the URL that Facebook is sending back?
     
  30. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    @prime31
    bump, it worked :) thanks!
    I edited my post above yours with a bonus question. Would be awsome if its possible :)
     
  31. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @haimmaik, you will want to either check the Graph API to add the like directly or check the Facebook dialogs to see if they have one for adding a like.
     
  32. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    @prime31 i'v researched about it quite alot yesturday. Its impossible to directly add a like with the graph API for security reasons.
    Im not sure about the dialogs. but what im trying to do is just open a facebook page on the facebook app via my app
     
  33. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @haimmaik, there is no web view available in the SocialNetworking Plugin. If you have the Etcetera Plugin it has a web view that you could use but you may want to check to see what dialogs Facebook has available. It is possible they have one for likes.
     
  34. haimmaik

    haimmaik

    Joined:
    Apr 18, 2010
    Posts:
    17
    @prime31 i dont have the Etcetera plugin.. and there's no "like" dialog unfortunately :S
    i guess ill have to use Application.OpenURL(string url) for now...

    I kinda hoped there's a way to open the Facebook application for page view purpose just like it's possible to open it for login purpose.
    might be a suggestion for a sweet feature of the social network plugin :)

    anyway, thanks m8 you helped me alot. <3
     
  35. sameer-mirza

    sameer-mirza

    Joined:
    Nov 14, 2011
    Posts:
    36
    Hi Prime,

    Is it possible to show an invite page with user's friends list etc. from within the plugin? I have tried to look at what types of dialogs you can use with FacebookBinding.showDialog but I'm not quite sure what parameters can go in there :S.

    A nudge in the right direction would help!

    Thanks :)
     
  36. sameer-mirza

    sameer-mirza

    Joined:
    Nov 14, 2011
    Posts:
    36
    Update: Found the way!

    the method FacbeookBinding.showDialog("apprequests", null) seems to give an error where as using a dictionary instead of the null seems to work just fine.

    So this is how the working code looks then:
    var dict = new Dictionary<string, string>();​
    dict.Add( "message", "Come check out my app" );​
    FacebookBinding.showDialog( @"apprequests", dict );​
     
  37. a28306

    a28306

    Joined:
    Sep 28, 2011
    Posts:
    11
    Great job! Keep it up! I'll try it in a future.
     
  38. Topsa

    Topsa

    Joined:
    Nov 21, 2011
    Posts:
    2
    Hi.

    Whe are developing twitter and facebook integration uring the Social Network plugin for iOS. And we notised that when the Twitter account user has enabled "Always use HTTPS" the TwitterPost failed and we got only the message "oAuth failed". We noticed that the twitter posting is done trough "http://api.twitter.com/...." and not "https://api.twitter.com/...." and this coused the error.

    Is there some reason the twitter posts are made trough http and not with https.

    -Topsa
     
  39. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @topsa, there is no particular reason why http is used. We will push out an update using https later today.
     
  40. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Ah! This might be the reason my posts are failing (although I swear it worked a couple of times and I never changed the https setting)! Also it seems to post for my artist, so I can only assume he doesn't have https checked. My account was set to use https. Is there a way to detect which method to use? Presumably you can't use https if the user has http checked, and vice versa? How can you tell which method to use?
     
  41. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Woo! It's working 100% (for now :)! I think that was my issue! I don't know why it was randomly working though. I managed to get a bunch of tweets last week, then nothing.
     
  42. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @sam, https will work in all situations.
     
  43. samizzo

    samizzo

    Joined:
    Sep 7, 2011
    Posts:
    487
    Awesome thanks!
     
  44. RobbieDingo

    RobbieDingo

    Joined:
    Jun 2, 2008
    Posts:
    484
    Hi Mike,

    I'm having great fun with the Social Networking Plugin - it's really great!

    One thing I'm having trouble with though is getting a call back to confirm that a post was successfully made:

    I'm doing this:-

    Code (csharp):
    1. var FBpostWasCompleted : boolean;
    2.  
    3. function Start () {
    4.  
    5.     // Flag, initially set to false.
    6.     FBpostWasCompleted = false;
    7.  
    8.     // Listen for Required Events:
    9.     SocialNetworkingManager.facebookPost += facebookPost;
    10.  
    11. }
    12.  
    13. function OnGUI(){
    14.  
    15.     if(FacebookBinding.isLoggedIn()){
    16.            
    17.         if(FBpostWasCompleted){
    18.                
    19.             GUI.Label -> saying "Shared OK"
    20.        
    21.         } else {
    22.            
    23.             // Share with FaceBook Now Button
    24.             if (GUI.Button (new Rect(0,0,100,100), "Share on Facebook", GUIText)){
    25.            
    26.                 // Post to FB
    27.                     var pathToImage = /X/Y/Z etc.
    28.                     FacebookBinding.postImage(pathToImage, "BLAH");
    29.    
    30.             }
    31.         }      
    32.  
    33.     } else {
    34.        
    35.         if (GUI.Button (new Rect(0,0,100,100), "Facebook Sign-In", GUIText)){
    36.             FacebookBinding.login();
    37.         }
    38.     }
    39. }
    40.  
    41.  
    42. function facebookPost(){
    43.    
    44.     FBpostWasCompleted = true;
    45.    
    46. }
    ... but for some reason it seems that 'FBpostWasCompleted' is never true?

    PS. The post does actually work OK - but facebookPost() does not seem to be fired afterwards?
     
    Last edited: Nov 22, 2011
  45. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Robbie, I am on my mobile but if I recall the postImage method actually kicks off the facebookReceivedCustomRequest event. If you drop the *EventManager prefab in your scene it will print the events as they fire.
     
  46. RobbieDingo

    RobbieDingo

    Joined:
    Jun 2, 2008
    Posts:
    484
    Thanks, yes, and you are right!...
     
  47. Jason-H

    Jason-H

    Joined:
    Nov 5, 2010
    Posts:
    87
    Hi Prime, I'm having an issue with the Facebook side of things. In short, after a user logs into facebook I automatically have the dialog box come up asking them to say something about it with an image and a link etc. But it then closes automatically after about a second or so. If they press the facebook button again the dialog box works properly and doesn't close automatically. I could do a nasty work around and make it pop-up twice once they login so the first gets automatically closed but the second stays up. Although I'm sure you'll agree that's not the nicest solution!

    Below is the code I've used along with a description of what's going on...



    The first time the user presses the facebook button within my app they are correctly taken to the web broswer on their device and asked to accept the app on the Facebook webpage.

    When they come back to the app if they have logged in successfully the facebookLogin event is fired in the "SocialNetworkingEventListener" script and that declares needToOpenFbDialogBox (a variable I've added) as true which then makes the LoadFB function run inside my SocialLevelComplete script.


    SocialLevelComplete script -

    Code (csharp):
    1. function OnGUI()
    2. {
    3.     var isLoggedInFB = FacebookBinding.isLoggedIn();
    4.     if( GUI.Button( new Rect(x1, y1, x2, y2), "", "FacebookBW" )  )
    5.     {
    6.         //this runs when they're not logged in
    7.         if (!isLoggedInFB)
    8.         {
    9.             if (Application.internetReachability != NetworkReachability.NotReachable )
    10.             {
    11.                 //User taken to web browser to login
    12.                 FacebookBinding.init("178############");
    13.                 FacebookBinding.login();
    14.             }
    15.         }
    16.         //this runs when they have already logged in
    17.         else
    18.         {
    19.             if (Application.internetReachability != NetworkReachability.NotReachable )
    20.             {
    21.                 FacebookBinding.showPostMessageDialogWithOptions (link, text1, urlString, message);
    22.             }
    23.         }
    24.     }
    25.     if (SocialNetworkingEventListener.needToOpenFbDialogBox)
    26.     {
    27.         LoadFB();
    28.         SocialNetworkingEventListener.needToOpenFbDialogBox = false;
    29.     }
    30. }
    31.  
    32. //this function loads when the "SocialNetworkingEventListener" script fires the facebookLogin bit.
    33. function LoadFB()
    34. {
    35.     //this yield sometimes prevented the dialog box from disappearing although it doesn't always work and this is where I'd like some help.
    36.     yield WaitForSeconds (4);
    37.     FacebookBinding.showPostMessageDialogWithOptions (link, text1, urlString, message);
    38. }
    39.  

    SocialNetworkingEventListener has had this part changed (along with a few other things)
    Code (csharp):
    1.     void facebookLogin()
    2.     {
    3.         //this is a static variable
    4.         needToOpenFbDialogBox = true;
    5.         Debug.Log( "Successfully logged in to Facebook" );
    6.     }

    Hopefully that all makes sense and you'll know why it's disappearing after being opened.

    Thanks,
    Jason.
     
  48. prime31

    prime31

    Joined:
    Oct 9, 2008
    Posts:
    6,426
    @Jason, it sounds like the Facebook SDK didn't have enough time to complete its post login process. I will shoot a bug report over to them with the details as long as I can reproduce. In the meantime, try waiting a bit before opening the dialog and see of that does the trick.
     
  49. ptdnet

    ptdnet

    Joined:
    Apr 20, 2011
    Posts:
    100
    Has anybody successfully posted a "LIKE" to their app? I just don't know enough about the Facebook API to get graphRequest(...) working correctly!

    From the docs, it seems like this should do it:
    Code (csharp):
    1. Hashtable hash = new Hashtable();
    2. FacebookBinding.graphRequest("https://graph.facebook.com/2960.../likes", "POST", hash);
    3.  
    2960... is my app's id.

    Right now I get back:
    The operation couldn’t be completed. (facebookErrDomain error 10000.)
     
    Last edited: Nov 22, 2011
  50. Jason-H

    Jason-H

    Joined:
    Nov 5, 2010
    Posts:
    87
    Hi Prime, thanks for the quick reply!

    I did try this in the code above with the yield statement in the "SocialLevelComplete" script. What's strange is that the yield seemed to fix it up until about a week ago but has now all of a sudden stopped working without me (knowingly) changing anything to do with the Social networking stuff whatsoever. Ahh the joys of coding!

    I've tried yielding from 0.5 to 10 seconds and nothing seems to help it.

    Is it possible Facebook may have changed something on their end that is causing this?

    And do you have any other suggestions?

    Thanks.