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

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

  1. FIllbiker

    FIllbiker

    New Member

    Joined:
    Jun 9, 2010
    Messages:
    107
    @DarkJedi - strange, everything is looks correct, no errors, but still work only on the 2nd click of the button. I tried to put higher number in WaitForSeconds, but no luck.
     
  2. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Fillbiker, you really need to use events when dealing with async operations. Try something like this:


    Code (csharp):
    1. function Start()
    2. {
    3.     SocialNetworkingManager.facebookLogin += facebookDidLoginSoDoThePost;
    4. }
    5.  
    6. function facebookDidLoginSoDoThePost()
    7. {
    8.     FacebookBinding.postMessageWithLink( "Test", "http://blabla.com", "test" );
    9. }
    10.  
    11.  
    12. function postToFacebook()
    13. {
    14.     if( !FacebookBinding.isLoggedIn() )
    15.     {
    16.         FacebookBinding.login();
    17.     }
    18.     else
    19.     {
    20.         facebookDidLoginSoDoThePost();
    21.     }
    22. }
    I wouldn't release a game with that but it should get you started. You really should to listen to the facebookLoginFailed event as well and handle when the user enters incorrect credentials.
     
  3. FIllbiker

    FIllbiker

    New Member

    Joined:
    Jun 9, 2010
    Messages:
    107
    @Prime31 - Ufff...thank you, I will try it. I need to play with that and this and DarkJedi's answer will be realy helpful!
     
  4. Hilm

    Hilm

    Member

    Joined:
    Nov 2, 2007
    Messages:
    317
    Hey,
    So I'm having some trouble with the social networking plugin running on OS 4.2.1. Essentially running under this OS 4.2.1 on iPod Touch it wont login to twitter, and when calling login to facebook it just starts opening the login dialogue but closes before you have chance to login (it just shows the spinner and then fades away as though it has detected it's already logged in - however it hasn't).

    I'm using the latest version of the plugin and it runs fine on 4.1 and 3.X. Only seems to be a problem on 4.2.1.

    In the debugger I'm getting the following error:
    "Facebook login failed: "

    and Twitter gets the following error:
    "Twitter login failed: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “api.twitter.com” which could put your confidential information at risk."

    But as mentioned, the code works fine on other OS's, it's only 4.2.1 that seems to have the problem.

    Any ideas as to a fix?

    Cheers,
    - Adam
     
    Last edited: Mar 17, 2011
  5. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    Hey prime,

    I'm trying to manage some delegates with the Social Networking plugin and I'm banging my head against the wall with the following error:

    'The name 'facebookLogin' does not exist in the current context'

    I have the SocialNetworkingManager attached to a object in the scene. I'm also using Etcetera and have no issue with a similar type assignment registering delegates with it. Strangely, the Event Listener script provided with the package registers and handles them perfectly, but I get the above error when trying to register them in my own script. Any ideas?

    SocialNetworkingManager.facebookLogin += facebookLogin;

    Thanks,
    Matt
     
  6. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Matt, I believe the error you are getting is because you don't have a method declared called "facebookLogin". It should look something like this:

    Code (csharp):
    1.     void facebookLogin()
    2.     {
    3.         Debug.Log( "Successfully logged in to Facebook" );
    4.     }
     
  7. Paulo Henrique

    Paulo Henrique

    Member

    Joined:
    Dec 12, 2010
    Messages:
    221
    @Matt I never used delegates and stuffs like before Prime31 show me the light, if you dont know it works like this:

    WHAT CAN HAPPEN += WHAT TO DO WHEN THIS HAPPENS;
    SocialNetworkingManager.facebookLogin += facebookLogin;

    When social plugin says "i´m logged on facebook" call the function: facebookLogin()
     
  8. QuietPixel

    QuietPixel

    New Member

    Joined:
    Jul 29, 2010
    Messages:
    51
    Hi Prime,

    Has the postMessageWithLinkAndLinkToImage function been removed? It no longer shows up in the docs on your website.
     
  9. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @QuietPixel, I have no idea how it got removed from the docs but I just put it back up.
     
  10. QuietPixel

    QuietPixel

    New Member

    Joined:
    Jul 29, 2010
    Messages:
    51
    @Prime, thank you! I went back to look at the docs, because for some reason, when I post with a picture link, the picture no longer shows up. Do you know if Facebook has changed their rules somehow to prevent pictures from being posted?
     
  11. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @QuietPixel, as far as I know there hasn't been any changes to their policy or API with regards to posting links.
     
  12. QuietPixel

    QuietPixel

    New Member

    Joined:
    Jul 29, 2010
    Messages:
    51
    Ok, now it just worked again, but I didn't change anything in the code. @Prime, I am curious, do you send the URL for the image to Facebook, or do you use the URL to first download the image, and then post the image at the same time as the message? The reason I ask is I am on a really slow cellular data card, and I see that in the console window, you code is saying it can't find the image. But the image is definitely out there at the URL I am using. My guess is your code is timing out if it can't find the image, and just posts the message without it. Is that correct?
     
  13. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @QuietPixel, Facebook handles dealing with the URL. I don't think they host it on their servers. I believe they just embed the image using the given URL but don't quote me on that one.
     
  14. QuietPixel

    QuietPixel

    New Member

    Joined:
    Jul 29, 2010
    Messages:
    51
    @Prime, Ok, Facebook must be having some problems on their side today. Thank you for the help, and the great plugin.
     
  15. U2

    U2

    Member

    Joined:
    Aug 12, 2008
    Messages:
    212
    Does anyone know if it's possible to extend the Facebook chat? It'd be nice if in my game a user could type something like fb: Some Name Some message and it'd send that user a msg through the fb chat. Or receiving you'd see fb: Some Name; How are you doing etc..

    As it is currently if you are actually in facebook and you look at the chat and you'll see who is online and if they are currently in an app that you share. It'd be nice to be able to see oh hey Joe Smith is currently playing such and such Unity game and send them a message which would show up in their game etc.. Not to mention it's not bad for advertising.
     
    Last edited: Mar 30, 2011
  16. gateway69

    gateway69

    Member

    Joined:
    Feb 18, 2010
    Messages:
    94
    Im running Unity 3.3pro, your plugin and socialnetworkingtestscene , i changed the fb app id value in one of the scripts but when I do a build first, it launches xcode, a finder window opens up, but when I try to build or run it on the ipad it spits out about 22 errors..

    also running xcode 4

    thoughts?

    Code (csharp):
    1.  
    2.  
    3. Undefined symbols for architecture armv7:
    4.   "__facebookShowPostMessageDialogWithMessage", referenced from:
    5.       RegisterMonoModules()     in RegisterMonoModules.o
    6.   "__facebookGraphRequest", referenced from:
    7.       RegisterMonoModules()     in RegisterMonoModules.o
    8.   "__twitterIsLoggedIn", referenced from:
    9.       RegisterMonoModules()     in RegisterMonoModules.o
    10.   "__facebookGetLoggedinUsersName", referenced from:
    11.       RegisterMonoModules()     in RegisterMonoModules.o
    12.   "__twitterLogin", referenced from:
    13.       RegisterMonoModules()     in RegisterMonoModules.o
    14.   "__facebookPostMessageWithLinkAndLinkToImage", referenced from:
    15.       RegisterMonoModules()     in RegisterMonoModules.o
    16.   "__facebookInit", referenced from:
    17.       RegisterMonoModules()     in RegisterMonoModules.o
    18.   "__facebookGetFriends", referenced from:
    19.       RegisterMonoModules()     in RegisterMonoModules.o
    20.   "__twitterLoggedInUsername", referenced from:
    21.       RegisterMonoModules()     in RegisterMonoModules.o
    22.   "__twitterInit", referenced from:
    23.       RegisterMonoModules()     in RegisterMonoModules.o
    24.   "__facebookIsLoggedIn", referenced from:
    25.       RegisterMonoModules()     in RegisterMonoModules.o
    26.   "__twitterGetHomeTimeline", referenced from:
    27.       RegisterMonoModules()     in RegisterMonoModules.o
    28.   "__facebookLogin", referenced from:
    29.       RegisterMonoModules()     in RegisterMonoModules.o
    30.   "__twitterLogout", referenced from:
    31.       RegisterMonoModules()     in RegisterMonoModules.o
    32.   "__facebookShowPostMessageDialog", referenced from:
    33.       RegisterMonoModules()     in RegisterMonoModules.o
    34.   "__facebookPostMessage", referenced from:
    35.       RegisterMonoModules()     in RegisterMonoModules.o
    36.   "__facebookPostImage", referenced from:
    37.       RegisterMonoModules()     in RegisterMonoModules.o
    38.   "__facebookShowPostMessageDialogWithOptions", referenced from:
    39.       RegisterMonoModules()     in RegisterMonoModules.o
    40.   "__facebookLogout", referenced from:
    41.       RegisterMonoModules()     in RegisterMonoModules.o
    42.   "__facebookPostMessageWithLink", referenced from:
    43.       RegisterMonoModules()     in RegisterMonoModules.o
    44.   "__twitterPostStatusUpdate", referenced from:
    45.       RegisterMonoModules()     in RegisterMonoModules.o
    46. ld: symbol(s) not found for architecture armv7
    47. collect2: ld returned 1 exit status
    48.  
     
    Last edited: Mar 31, 2011
  17. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @gateway69, shoot me an email at questions (@) prime31.com and I'll get you a copy of the new post process build system for Xcode 4 that is currently in beta.
     
  18. U2

    U2

    Member

    Joined:
    Aug 12, 2008
    Messages:
    212
    Just looking into this myself a bit. It does in fact look like Facebook has a chat API now which allows 3rd party apps to interact.

    http://developers.facebook.com/docs/chat/

    Any chance you think you will be able to work it into your kit?
     
  19. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @rutecht, Facebook chat is outside the scope of the SocialNetworking Plugin. It was really made for getting highscores and achievements out to the world not 1-to-1 communications. If there was enough requests we could wrap up the Facebook chat in a plugin but (I could be wrong on this one) I don't think there are enough folks out there that would want it. Chat in a mobile game is awkward with no keyboard but who knows perhaps some of the great Unity devs out there have some good ideas on how to use it.
     
  20. karn9872

    karn9872

    New Member

    Joined:
    Sep 26, 2010
    Messages:
    14
    Hi Mike,

    Just upgrading to the latest plugin for the Facebook change. In your documentation you mention that a Prime31 menu item will show up in Unity, but I always receive an error for the P31MenuItem.cs file and I have to remove it from my Unity project. I'm running the latest of everything. The errors are:

    Thanks for your help.
     
  21. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @karn9872, are you sure you are using Unity 3.3? The System.Process class should be available with the Mono install that Unity comes with. Worst case, just remove the entire troubleshooter() method and see if that does the trick for you.
     
  22. karn9872

    karn9872

    New Member

    Joined:
    Sep 26, 2010
    Messages:
    14
    Yep, version 3.30f4. Your fix did the job. I should have thought of that. Thanks, again!
     
  23. qamarzaman

    qamarzaman

    New Member

    Joined:
    Jul 1, 2010
    Messages:
    85
    Hey Prime,
    I,ve just got the Prime31 Social Integration plugin, I am having problem in posting image to facebook , I am unable to login from my app and correspondingly not able to post status on twitter.

    I am following the guide in documentation.

    Please help, i want to get out of this Headache
     
  24. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    Prime,

    I upgraded to the latest plugin update... no problem with the schema... but every time I try and call the login method for FB, it takes me to the FB app and displays a dialog that I have already initialized my game, press OK to continue. After pressing OK it takes me to my wall, but nothing is posted.

    isLoggedIn is returning false before I call this method, and I have a delegate set up to post the message with options once the login is successful.

    Any ideas?

    Matt
     
  25. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Matt/@qamarzaman, after logging in to Facebook if the url scheme was properly setup it should bounce you back to your game and you should be clear to post. Are you seeing something different? Did you double check your plist to ensure you have the url scheme in there?
     
  26. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    Hey Prime,

    I went back and checked everything again and noticed that my FB key was one digit short of what it should have been. I copied it back to the info.plist additions window drop down in Unity and it appeared as though it immediately truncated the last digit? I pasted it a couple more times and it then "stuck" with the full string. Not sure if this is a bug, but once I built with the full string it did bring me back to the app after login.

    Thanks,
    Matt
     
  27. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Hello Prime,

    one question about Facebook connectivity. Each time I use FacebookBinding.login(), I got the screen from Facebook with the error message "you have already authorized <my app>. clic OK to continue"

    on the iPhone, Facebook app is logged but the FacebookBinding.isLoggedIn() reports FALSE until I use Login().

    Once I'm logged (I just click on 'OK' or on 'Cancel' button on the Facebook screen), then I'm able to post.

    thank you for your help.

    hervé
     
    Last edited: Apr 12, 2011
  28. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, so, when you call isLoggedIn it always returns false? Have you checked to see if there is an accessToken? Perhaps using that as an indicator will work for you.
     
  29. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Hello Prime,

    Why should an AccessToken should be there ? I just want to post on a facebook page so the app does not requires specific rights.

    if so, how should I test this ?

    Code (csharp):
    1. print(FacebookBinding.getFacebookAccessToken());
    return NULL.

    thank you.

    hervé
     
    Last edited: Apr 13, 2011
  30. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, without an access token you can't get any information from Facebooks server and you cant post to Facebook. You will need to go through the login process first then either use postMessage or any of the dialogs.
     
  31. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Prime,

    I created the app on facebook/developer. Then I copied the App Id to use it in the login() function.

    Am I supposed to do something help in order to be able to Post ?

    - created the App on facebook.com/developer
    - copy the App Id and put in Init() function
    - test IsLoggedIn() return false
    - so I use Login() and then I got this page from facebook telling me that the app is already authorized...


    thank you for your help.
     
    Last edited: Apr 13, 2011
  32. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, be sure to read the documentation. Facebook's single sign on requires extra steps to setup. There is a video tutorial in the documentation as well.
     
  33. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Hello Prime,

    i did this extra step :)
    I read the doc and saw the video. I'm pretty sure I've got everything done by now. should I look somewhere else ?

    the xcode app contains the facebook ID under URL types > Item 0 > URL Schemes > Item 0
     
    Last edited: Apr 13, 2011
  34. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, have you tried the demo scene to see how it works? It demonstrates posting messages directly and via a dialog.
     
  35. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Prime,

    I just did. the only thing I changed is that I put my App Id in the Init() function and get the same result. any idea ?
     
  36. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, are you calling the login method right after init? are you being redirected to the Facebook app or webpage? do you see any errors in the Xcode log?
     
  37. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Init and login are sequential. I'm pushed to www.facebook.com/connect/uiserver.php?app_id=20061458664XXXX.....

    Code (csharp):
    1.        
    2. if (iPhoneSettings.internetReachability != iPhoneNetworkReachability.NotReachable)
    3. {
    4.     FacebookBinding.init( "20061458664XXXX" );
    5.  
    6.     bIsFacebookLogged = FacebookBinding.isLoggedIn();
    7.     if(!bIsFacebookLogged)
    8.     {
    9.         FacebookBinding.login();
    10.     }
    11.            
    12. }
    13.  
     
  38. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, do you get redirected back to your app after logging in?
     
  39. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Hello,

    Yes. If I click "ok", then I'm redirected and logged in Facebook. If I clic "Cancel", then I'm not logged in Facebook.
     
  40. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, that means that either your appId isn't setup properly or your url scheme isn't setup properly. Facebook will attempt to redirect back to your app using the url scheme that is in your Info.plist. You may also want to delete the app from your device and reinstall. Sometimes plist changes don't get copied over without a delete first.
     
  41. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Hello Prime,

    I'm stuck. deleted the app on both ipad and iphone, still the same error...

    plist seems to be correct.
     
  42. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, shoot me an email at questions (at) prime31.com and ill send you a fully functioning project. You can test it out and compare to yours to see what may be missing.
     
  43. the_golden_gunman

    the_golden_gunman

    New Member

    Joined:
    Feb 15, 2011
    Messages:
    17
    Hi Prime,

    I've recently purchased the Social Networking plugin. I've successfully integrated Facebook, but I'm having problems with Twitter. I've applied to Twitter to request the use of xAuth, but I've had my request turned down! I'd like to be able to test my app with Twitter, so I was wondering if there is anyway to implement Twitter integration using the plugin without the use of xAuth?
     
  44. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @golden, Twitter turned you down? Those guys really have been stomping indie developers lately. The plugin currently requires Xauth but if Twitter is going to start turning down people for Xauth approval I'll see about changing the plugin to use plain Oauth. The problem with that then becomes that you need to email Twitter to put in a custom callback URL and who knows of they will allow that anymore...
     
  45. the_golden_gunman

    the_golden_gunman

    New Member

    Joined:
    Feb 15, 2011
    Messages:
    17
    Yeah I was pretty surprised about being turned down too, but that's the official response I received from Twitter.
     
  46. azeitler

    azeitler

    Member

    Joined:
    May 14, 2008
    Messages:
    161
    There seems to be a problem with continuous authorization (only authorize game once and send posts for an unlimited without re-authorization).

    I use the offline_access permission, but the app tries to authorize each time it starts, because isLoggedIn seems to return false every time, which in turn is caused by the Plugin not storing expirationDate and accessToken for later reference.

    Anyone else here who has also had trouble with this issue?
     
  47. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @azeitler, try grabbing the latest package. A workaround was added for this behavior.
     
  48. azeitler

    azeitler

    Member

    Joined:
    May 14, 2008
    Messages:
    161
    got it, works, thanks!
     
  49. Kortekk

    Kortekk

    New Member

    Joined:
    Sep 25, 2009
    Messages:
    20
    Is there any way with the current plugin to generate a Facebook post with the exact same contents as the postMessageWithLinkAndLinkToImage method except using a raw image file (eg. game screenshot)? Or is this something that Facebook doesn't allow? I'd like to be able to create a post with a link and a dynamically generated screenshot.
     
  50. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Kortekk, their post methods don't have the parameters to pull that off. You can work around that by posting the image to a website then using the postMessageWithLinkAndLinkToImage method to post a link to it. If you just need a link without an image you can just put the link in the body of the message also.