Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Anybody tried to use FB plug-in? — Gideros Forum

Anybody tried to use FB plug-in?

RickyngkRickyngk Member
edited October 2012 in General questions
I'm trying to do something with facebook plug-in. Thanks to guild-line
Download and install Facebook SDK from <a href="https://developers.facebook.com/ios/downloads/" rel="nofollow">https://developers.facebook.com/ios/downloads/</a>
Add FacebookSDK.framework to your project.
Add the backward compatibility headers as described <a href="https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/#step2" rel="nofollow">https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/#step2</a>
Add {Gideros Installation Directory}/All Plugins/Facebook/source/iOS/* files to your Xcode project.
If enabled, disable “Application does not run in background” property in .plist file.
I've got 10 link errors because of missing some relative frameworks such as Accounts.framework, AdSupport.framework. After adding both, I've next issue: "Library not loaded ... reason: image not found" caused by AdSupport

:((

Any better guild-line (and some basic examples :D )?

Thanks,

Edit:
Solve "Library not loaded ... " by setting Accounts.framework, AdSupport.framework to optional, not required

Comments

  • @atilim: would you please give me (us) a demo how to use (or more detail document). I don't know how to work with fb plug-in
  • atilimatilim Maintainer
    edited November 2012 Accepted Answer
    Hi all,

    Here are some more info:

    1. You need to download and install Facebook iOS SDK. If you're using Xcode 4.5+iOS 6 SDK, you can download the latest one (currently 3.1.1). If you want to stick with pre Xcode 4.5, you need to download version 3.0.8 from https://github.com/facebook/facebook-ios-sdk/downloads
    2. If you're using Xcode 4.5 + iOS 6 SDK, add Accounts.framework, AdSupport.framework to your project
    3. Add FacebookSDK.framework to your project.
    4. Add the backward compatibility headers as described https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/#step2
    5. Add {Gideros Installation Directory}/All Plugins/Facebook/source/iOS/* files to your Xcode project.
    6. If enabled, disable “Application does not run in background” property in .plist file.
    7. Add URL Scheme as fbYOUR_APP_ID to .plist file as shown in the screenshot.

    After these steps, if you can build GiderosiOSPlayer without any problem, we're ready for some coding. Here is a part of my test code:
    require "facebook" 
     
    facebook:setAppId("204825239647607")
     
    facebook:addEventListener(Event.LOGIN_COMPLETE, function() print("login complete") end)
    facebook:addEventListener(Event.LOGIN_ERROR, function() print("login error") end)
    facebook:addEventListener(Event.LOGIN_CANCEL, function() print("login cancel") end)
    facebook:addEventListener(Event.LOGOUT_COMPLETE, function() print("logout complete") end)
    facebook:addEventListener(Event.DIALOG_COMPLETE, function() print("dialog complete") end)
    facebook:addEventListener(Event.DIALOG_ERROR, function(event) print("dialog error", event.errorCode, event.errorDescription) end)
    facebook:addEventListener(Event.DIALOG_CANCEL, function() print("dialog cancel") end)
    facebook:addEventListener(Event.REQUEST_COMPLETE, function(event) print("request complete", event.response) end)
    facebook:addEventListener(Event.REQUEST_ERROR, function(event) print("request error", event.errorCode, event.errorDescription) end)
     
    local function loginlogout()
    	if facebook:isSessionValid() then
    		facebook:logout()
    	else
    		facebook:authorize({"email"})
    	end
    end
     
    local function feedExample()
    	local params = {
    		name = "Facebook SDK for iOS",
    		caption = "Build great social apps and get more installs.",
    		description = "The Facebook SDK for iOS makes it easier and faster to develop Facebook integrated iOS apps.",
    		link = "<a href="https://developers.facebook.com/ios"" rel="nofollow">https://developers.facebook.com/ios"</a>,
    		picture = "<a href="https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png&quot" rel="nofollow">https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png&quot</a>;
    	}
     
    	facebook:dialog("feed", params)
    end
     
    local function requestExample()
    	local params = {
    		message = "Check out this awesome app"
    	}
    	facebook:dialog("apprequests", params)
    end
     
    local function graphPathExample()
    	facebook:graphRequest("me/friends")
    end
    Hope this helps
    URL_Scheme.png
    472 x 82 - 13K

    Likes: fxone

    +1 -1 (+1 / -0 )Share on Facebook
  • I wonder that where I can look up param member (such as name, caption, description, ...).
    I'm downloading new version 2012.9.2, hope offline API document has already updated this stuff ;)
  • atilimatilim Maintainer
    edited November 2012
    Facebook:dialog(...) and Facebook:graphRequest(...) function can accept lots of parameters.

    You can find the official documentation
    For dialogs: https://developers.facebook.com/docs/reference/dialogs/
    And for graph requests: https://developers.facebook.com/docs/opengraph/
  • Hey @atilim, I followed the FB install instructions above and built the player to my phone then tried to run my app (including your sample code above for testing) but it fails with:

    main.lua:65: module 'facebook' not found:
    no field package.preload['facebook']
    no file './facebook.lua'
    no file '/usr/local/share/lua/5.1/facebook.lua'
    no file '/usr/local/share/lua/5.1/facebook/init.lua'
    no file '/usr/local/lib/lua/5.1/facebook.lua'
    no file '/usr/local/lib/lua/5.1/facebook/init.lua'
    no file './facebook.so'
    no file '/usr/local/lib/lua/5.1/facebook.so'
    no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:

    I'm guessing I missed a step somewhere in the setup, though I did follow the FB SDK installation video and all your steps above as far as I can tell.

    Does anything need to be added to the AppDelegate.h to import "gfacebook.h" or "facebook.h"?

    And for step 5, where should those files be added to in the project? just the base project dir or the plugins dir?
    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
  • OK, I managed to figure out the issue. Although I had added the files in step 5 to my project, I had to also add them to the compile sources:
    - add facebookbinder.cpp and gfacebook-ios.mm to the Build Phases > Compile Sources

    This threw one additional error about not finding gfacebook.h, so I had to change the top import line in gfacebook-ios.mm from:
    #import
    to
    #import "gfacebook.h"

    It then built successfully and I was able to publish a feed to my wall.

    Likes: thanhquan1512

    [ Twitter: pushpoke | Facebook: facebook.com/pushpoke | Web: pushpoke.com | Letter Stack iOS: letterstack.com ]
    +1 -1 (+1 / -0 )Share on Facebook
  • Does this plugin support Android? If not when will it be available for Android?

    Likes: achimeno

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • Hello all,
    I'm integrating Facebook in Save my toys and I found a problem with the "Cancel button", it dispaches DIALOG_COMPLETE

    In case someone might be interested, I solved this changing the gfacebook-ios.mm
    ...
    // FBDialogDelegate
    - (void)dialogDidComplete:(FBDialog *)dialog
    {
    //    if (facebook_)
    //        facebook_->dialogDidComplete();
    }
     
    - (void)dialogCompleteWithUrl:(NSURL *)url
    {
        if ([url.absoluteString rangeOfString:<a href="http://forum.gideros.rocks/profile/post_id%3D" rel="nofollow">@post_id=</a>].location != NSNotFound) {
            // user pressed "Send"
            if (facebook_)
                facebook_->dialogDidComplete();
        } else {
            // user pressed "Cancel" button (although not the circle with X)
            if (facebook_)
                facebook_->dialogDidNotComplete();
        }
    }
     
    - (void)dialogDidNotCompleteWithUrl:(NSURL *)url
    {
        if (facebook_)
            facebook_->dialogDidNotComplete();
    }
    ...

    Likes: hgvyas123, omer

    +1 -1 (+2 / -0 )Share on Facebook
  • I've got the hang of most parts of the facebook plugin and graph API but I have a question about the plugin. All of the facebook graph api's require a facebook access token which I assume is held within the plugin. This token also expires, so I see the method "extendAccessToken". My question is if the token expires, do I need to reauthorize the app with the user using "authorize" method, or is extending the access token good enough?
  • From your perspective you only need to call login, and user will be authorized (or reauthorized if needed) internally
  • Well I realize I haeveto authorize at least once. However, if the sessions is no longer valid do I have to reauthorize again or is extending just the access token enough?
  • now looking at the code, actually if session is no longer valid, login function will reauthorize it which will extend the token automatically
  • edited September 2013
    OK, I managed to figure out the issue. Although I had added the files in step 5 to my project, I had to also add them to the compile sources:
    - add facebookbinder.cpp and gfacebook-ios.mm to the Build Phases > Compile Sources

    This threw one additional error about not finding gfacebook.h, so I had to change the top import line in gfacebook-ios.mm from:
    #import
    to
    #import "gfacebook.h"

    It then built successfully and I was able to publish a feed to my wall.
    Additional notes:

    1. If you get error in #include < Facebook.h > then check steps 4 (add DeprecatedHeader folder from FacebookSDK to your Frameworks folder in project tree), edit to #import "Facebook.h"

    2. If you get error related FBCrypto.o and you are using Facebook SDK 3.5 then add Security.framework to your project
Sign In or Register to comment.