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

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

  1. Gigiwoo

    Gigiwoo

    Member

    Joined:
    Mar 16, 2011
    Messages:
    1,835
    Dumb question. If you can't send your image to facebook, where are you supposed to put the image to get a link?

    Gigiwoo.
     
  2. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @gigiwoo, you can send it to your own server or any of the various image hosts out there. Or you can just use the postImage method and post it directly to Facebook.
     
  3. ForrestX

    ForrestX

    Member

    Joined:
    Apr 17, 2010
    Messages:
    78
    Does anyone have a "POST" example using Facebook graph api?
    I want to post an image with text and then commenting/like it!
    I've read the facebook docs with no luck :(

    thx

    EDIT: found by myself
     
    Last edited: Apr 21, 2011
  4. ForrestX

    ForrestX

    Member

    Joined:
    Apr 17, 2010
    Messages:
    78
    @prime
    Reading facebook graph api and some tutorials, I saw that every post method must return an object_id.
    If you post an image and then want to comment or like it, you need to have the id..
    Maybe you could add this in some way?

    thx
     
  5. matt.johnson

    matt.johnson

    New Member

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

    Im in the process of porting my App to iPad, and was assuming that I could use the same FB / Twitter keys for posting from the new app, but nothing is posting to the Twitter feed and FB errors out each time. Does each unique app ID have to have a different App set up with Twitter / FB?

    Thanks,
    Matt
     
  6. mehware

    mehware

    New Member

    Joined:
    Nov 19, 2007
    Messages:
    742
    Bought this last night on an impulse buy, its great. From the docs I got er up and running in 5 mins and posting to my feed!

    Thanks Prime31!
     
  7. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Matt, you should be fine with the same appId in an iPad and iPhone app. Try the demo scene with your appId on both devices and it should work fine.

    @mehware, glad to hear you got up and running painlessly!
     
  8. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    @prime, I actually have two different app IDs (one for iPhone / iPod and now one for iPad). I'm assuming you have to create a new app ID, gamecenter leaderboards, etc. because it is going to be sold as two separate apps? If that is the case, can both unique binaries not use the same Twitter / FB application / keys?

    Thanks,
    Matt
     
  9. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Matt, oh, you aren't doing a universal binary... For GameCenter you need to have separate everything but for Facebook/Twitter you are fine sharing the appId and secret.
     
  10. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    @ok, thanks... thought that was the case, but I'm having issue with nothing being posted to the Twitter feed and "An error occurred with (app name). Please try again later." for Facebook. Ill try different hardware, but the only thing I changed in the code was the app id (none of the keys) and it works find under the old app id (on the phone).

    Thanks,
    Matt
     
  11. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Matt, try deleting the app from your device and reinstalling. Sometimes Xcode caches some files that changed.
     
  12. matt.johnson

    matt.johnson

    New Member

    Joined:
    May 7, 2009
    Messages:
    67
    It magically starting the 2nd time I deleted and reinstalled ;). Guess its somewhat of a crap shoot at times. Thanks for the tip.

    MJ
     
  13. ciaravoh

    ciaravoh

    New Member

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

    I still having a problem with Facebook connection. I have deleted and re-created the application. change the ID in the code and in the plist but each time I launch the application, I have this screen telling me "You have already authorized iLTC. Click OK to continue"

    any idea ?

    thank you.
     
  14. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, first off are you using the latest version? There was a small fix to the isLoggedIn method that seems like it may be related.
     
  15. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    HA !!!! let me download it and I'll tell you. thanks.
     
  16. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Sorry Prime.... same error. I really don't know what to do here... Any idea ?

    thank you.

    Code (csharp):
    1.  
    2.     void Start()
    3.     {
    4.        
    5.         if (iPhoneSettings.internetReachability != iPhoneNetworkReachability.NotReachable)
    6.         {
    7.             FacebookBinding.init("203422XXXXXXXXX");
    8.            
    9.            
    10.             bIsFacebookLogged = FacebookBinding.isLoggedIn();
    11.             if(!bIsFacebookLogged)
    12.             {
    13.                 FacebookBinding.login();
    14.             }
    15.            
    16.         }
    17.        
    18.     }
    19.  
    for my info, the Key API is not used for facebook ? only the APP ID ?

    thanks
     
    Last edited: Apr 21, 2011
  17. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, that looks about right to me. The isLoggedIn call maps to a call to the Facebook library to see if the session is valid. Can you try doing a check to see if an access token is available (getFacebookAccessToken)? Perhaps the token is available but for some reason FB is saying the session isn't valid.
     
  18. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Mike,


    the getFacebookAccessToken() returns Null.

    for information, I have FacePad install on the device. does it help ?

    hervé
     
  19. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, what happens when you plug your own appId into the demo scene? I can't reproduce any of the issues you are having with it.
     
  20. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Mike,

    Exactly the same issue....
     
  21. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, I am trying to reproduce what you are seeing and on 3 different devices so far all is well...
     
  22. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Mike,

    I'll have to find another way to publish to facebook.

    thank you anyway.

    hervé
     
  23. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Mike,

    I try to summarize. Can you please confirm that the App ID must have 'fb' first when enter in the plist editor (in unity) ?
    Is the Init() method must contain 'fb' + AppID or only the AppId ?
    Is there a specific setup for Application in facebook.com/developers ?
    is there a problem when the official facebook is install on the device ?
    why the secret is not used ?

    thank you for your help.
     
  24. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciarovoh, you are correct, you must put 'fb' + appId in the plist editor. You can confirm this is working by doing a login() and if control bounces back to your app it is up and running properly.

    init() only takes the appId without the 'fb'.

    for app setup, I didn't modify any settings at all for my apps.

    the official app will be used to authenticate if it is available. If not, Safari will be used.

    i have no idea why the secret isn't used for mobile. I guess Facebook feels the appId + url scheme is enough security. if you shoot me an email (questions at prime31.com) I can send you the demo scene Xcode project with my appId in it so you can see how it is all supposed to work.
     
  25. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Mike,

    I sent you an email with the screenshot of facebook page "you have already authorized <application>"

    please have a look. Thank you.

    hervé
     
  26. ForrestX

    ForrestX

    Member

    Joined:
    Apr 17, 2010
    Messages:
    78
  27. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    thank you ForrestXY. At least we know now. I'll have a look to your post and +1 on it.
    thanks.
     
  28. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    Just a quick heads up: we just released the NectarSync Plugin! This is the feature that every mobile game needs: WiFi syncing of saved game state. With one line of code you can transfer all of your PlayerPrefs and the entire contents of the Documents directory from one iOS device to another. Start playing a game on the iPhone while on the go then just transfer the saved state to your iPad and continue right where you left off!
     
  29. ciaravoh

    ciaravoh

    New Member

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

    any news on that bug ? I've received 2 or 3 mails from fb but the bug is supposed to be still there...

    thanks for the update.

    hervé
     
  30. ForrestX

    ForrestX

    Member

    Joined:
    Apr 17, 2010
    Messages:
    78
    unfortunately not
    the current bug status is Triaging. Will follow up.
     
  31. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Thank you.

    They have updated yesterday with some recommendations. did you follow them ?

    I've deleted and recreated the application in Facebook and it works for a while. But now this is back to the bug for authorization.

    thanks.
     
  32. ForrestX

    ForrestX

    Member

    Joined:
    Apr 17, 2010
    Messages:
    78
  33. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @forrest, it appears FB doesn't know how their own API works. Calling authorize does not use the in app popup for authentication unless the app doesn't support fast app switching or is on an older device. They linked to a page that even tells you to setup a URL scheme which is how they send control back to your app after leaving it.
     
  34. jsr2k1

    jsr2k1

    Member

    Joined:
    Aug 11, 2010
    Messages:
    26
    @Prime

    I can't post a message using the function "postMessage" and I can't post an image with "postImage"
    but with "showPostMessageDialog" it works ok and I see the post in my wall.

    When I ask if user is logged in always returns false with "isLoggedIn"
    and when I use "postMessage" or "postImage" the result in debugger is:
    ----------------
    (Filename: /Applications/buildAgent/work/71ca6fec1b41cc30/Projects/../ Runtime/Export/Generated/BaseClass.cpp Line: 2528)

    facebookCustomRequestFailed failed: The operation couldn’t be completed. (facebookErrDomain error 10000.)
    -----------------

    In the facebook/developers web page I check this option:
    Mobile and Devices -> Core Settings -> Application Type = HTML5/mobile web
    (instead of: Native App)

    Any idea?

    Thanks,

    Joel
     
    Last edited: May 1, 2011
  35. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Joel, I believe error 10000 means you don't have permission to do that which would explain why postMessage fails and the dialog succeeds. The dialog is really just the user posting a message while postMessage is you doing it on behalf of the user. Be sure you have the publish_stream permission. I don't know if changing your FB app type has any effect on the way the API works but I can say that using the default app settings does work.
     
  36. jsr2k1

    jsr2k1

    Member

    Joined:
    Aug 11, 2010
    Messages:
    26
    @Prime, ok, but how can I have the publish_stream permission? I can't see the option in developers.facebook.com
     
  37. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @jsr2k1, try this from the Social Networking Plugin docs:

    // Opens the Facebook single sign on login in Safari or the official Facebook app with the requested permissions
    public static void loginWithRequestedPermissions( string[] permissions )
     
  38. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Well, this is strange how fb ignore how their interface runs. I now have a better behaviour but on a regular basis, I still have the 'authorization already given' pages. that's crap...
     
    Last edited: May 2, 2011
  39. squidbot

    squidbot

    Member

    Joined:
    Jan 4, 2011
    Messages:
    126
     
    Last edited: May 3, 2011
  40. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Thank you Squidbot, I'll try in a minute. just not sure about the [] syntax in c#.
    I'll let you know.
     
  41. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @ciaravoh, for C# just do something like this:

    Code (csharp):
    1. FacebookBinding.loginWithRequestedPermissions( new string[] { "publish_stream", "offline_access" } );
     
  42. ciaravoh

    ciaravoh

    New Member

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

    it works fine !

    Code (csharp):
    1.                 string[] sAut = new string[] {"publish_stream", "offline_access"};
    2.                 FacebookBinding.loginWithRequestedPermissions(sAut);
    3.  
    I've made the change and it's fine now. login asked me once to authorize the app and now I'm done. I'll wait a few hours to ensure the credential are still there over time and I'll post again.

    Mike,

    you should update you documentation with that remark.

    thanks for the help.
     
  43. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    Your wish is my command. Documentation updated :)
     
  44. ciaravoh

    ciaravoh

    New Member

    Joined:
    Dec 16, 2009
    Messages:
    237
    Excellent. thank you Prime and Squidbot. so much time saved here.
    I publish a new version of my app just now ;-)
     
  45. qamarzaman

    qamarzaman

    New Member

    Joined:
    Jul 1, 2010
    Messages:
    85
    Hi Prime
    For twitter integration, I sent an email to api@twitter.com to get my app authorized in order to being able to login an post status on twitter page. But I got this replay:

    What is wrong i am still not able to post to twitter
     
  46. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    Twitter. They hate developers more and more every day. We'll see what we cam do about removing Xauth completely and going with an Oauth solution.
     
    Last edited: May 9, 2011
  47. jsr2k1

    jsr2k1

    Member

    Joined:
    Aug 11, 2010
    Messages:
    26
    @Prime

    Hello again, I tried your suggestion about permission and it works correctly on my iPod, but it doesn't work on my iPhone. It's weird, I use exactly the same code and the same published app in both devices.

    Is there a reason for this?

    Joel
     
  48. prime31

    prime31

    Member

    Joined:
    Oct 9, 2008
    Messages:
    6,424
    @Joel, there is definitely no reason for that. What I am thinking happend is that you didnt delete the app from your iPhone before reinstalling. Sometimes Xcode doesn't properly copy the updated files to your device. Once all is working, you don't have to worry about deleting before reinstalling.
     
  49. playforhumanity

    playforhumanity

    New Member

    Joined:
    Sep 10, 2009
    Messages:
    33
    Bought this plugin 2day, everything going well, Mike at prime31 is very helpful.
     
  50. unseenthings

    unseenthings

    Member

    Joined:
    Nov 12, 2009
    Messages:
    32
    ciaravoh: I'm having the same exact issue you were having, and I have been for several days, with the exception of the fact that mine still doesn't work. I've tried creating a new app, deleting the old one, removing and re-adding, new builds, new projects and just about everything else I can think of... do you know what the key to fixing your main issue was? I'm still getting the facebookErrDomain error 10000 errors and the Null token when I check for it. Any advice would be much appreciated.