Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Whats the current Facebook method please — Gideros Forum

Whats the current Facebook method please

ArtLeeAppsArtLeeApps Member
edited March 2014 in General questions
Hi all,

I saw some post saying the next version of Gideros may include the Facebook plugin etc.

I now want to add code to work for both IOS and Android.

I would have to download the SDKs for IOS and the Android.

With all the posts/changes how do you know/find the latest best practise for using this in IOS and Android ?
Is the Gideros Code different for both platforms ?


The last time i used Facebook was for the Android setup. with code like below.
would that have changed ?
 
require "facebook"	
 
facebook:setAppId("<my big number>");
facebook:authorize({"publish_actions"});
 
 
--.... some time later......
 
 
 
facebook:graphRequest("me/feed", {
 link = "<a href="http://blah.com/"" rel="nofollow">http://blah.com/"</a>, 
 picture = "<a href="http://icon.png"" rel="nofollow">http://icon.png"</a>, 
 name = "Blah", 
 caption = "Blah", 
message = "Blah"
},"POST")

Comments

  • The new one in labs is better - it also works on both iOS and Android.
    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
  • ar2rsawseenar2rsawseen Maintainer
    Hello,
    There is a new version in the Labs for the latest Facebook SDKs and supporting some more stuff (as posting pictures)

    It's marked as experiment, but I released an app with it (Kicky Ball), and for now it seems to work ok.

    So you can try it:

    http://giderosmobile.com/labs/facebook

    The usage changed a bit, but on the other hand is also a little easier providing some wrapped methods for common tasks and returning graph path in the event, to know which request returned the result
    --authentication
    login(appId, permissions)
    logout()
     
    --requests information
    get(path, params) --general request for any graph query
    getProfile(params)
    getFriends(params)
    getAlbums(params)
    getAppRequests(params)
    getScores()
     
    --publish information
    post(path, params) -- general post for any information
    postScore({score: 123})
    postPhoto(path, {message: , place: , album:})
    postToFeed({message, link, picture, name, caption, description})
     
    --delete
    delete(objectId) --id of the object to delete
     
    --dialogs
    dialog(type, params)
    inviteFriends({message, to, suggestions})
    share({message, link, picture, name, caption, description})
    Events
    Event.LOGIN_COMPLETE
    Event.LOGIN_ERROR --contains (e.errror)
    Event.LOGOUT_COMPLETE
    Event.LOGOUT_ERROR --contains (e.errror)
    Event.DIALOG_COMPLETE --contains (e.type)
    Event.DIALOG_ERROR --contains (e.type, e.errror)
    Event.REQUEST_COMPLETE --contains (e.type, e.response)
    Event.REQUEST_ERROR --contains (e.type, e.errror)
     
    --e.type is basically type/path you passed to graph request or dialog, 
    --so you would know from what request are you receiving the response
  • @ar2rsawseen You have a spelling mistake in your docs

    Event.LOGIN_ERROR --contains (e.errror)

    should be
    Event.LOGIN_ERROR --contains (e.error)

    (I hope) :)
    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
  • @SinisterSoft, that's an Errror ;)

    Likes: SinisterSoft

    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
    +1 -1 (+1 / -0 )Share on Facebook
  • :D
    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
  • ar2rsawseenar2rsawseen Maintainer
    ha, ha, ha
    The doc scraps are usually the last part I make after plugin, which is usually in a deep deep night (or almost morning) :)
  • Hi @ar2rsawseen,

    I thought i was going well. doing a fresh setup in eclipse and understanding what i was actually doing.

    I added the FACEBOOK folder to the Exported project folders.
    refreshed/built, and i got the attached. error. :(

    sorry.
    Capture2.GIF
    778 x 322 - 68K
  • ar2rsawseenar2rsawseen Maintainer
    @ArtLeeApps Example activity is meant just for example on how the activity should be modified, you don't need to copy it
    Just modify your own activity in the same way ;)
  • Oh.......... (long silence during that awkward moment........)

    Yes of course, ill go and whack my programmer over the head for that mistake.

    thank you.
  • Arghhhhhh

    Now i have : all in red. it can't find "com.facebook"
    i have copied the "Facebook" plug in to "plugins".


    import com.facebook.FacebookException;
    import com.facebook.FacebookOperationCanceledException;
    import com.facebook.FacebookRequestError;
    import com.facebook.HttpMethod;
    import com.facebook.Request;
    import com.facebook.RequestAsyncTask;
    import com.facebook.Response;
    import com.facebook.Session;
    import com.facebook.model.GraphObject;
    import com.facebook.widget.WebDialog;
    import com.facebook.widget.WebDialog.OnCompleteListener;
  • ar2rsawseenar2rsawseen Maintainer
    You need to add Facebook SDK (either provided with the labs or download new one)
    and then reference it from your project, because now it seems it simple does not see the sdk (or your current SDK is outdated)
  • ArtLeeAppsArtLeeApps Member
    edited March 2014
    sorry for all this stuffing around.

    I had downloaded the latest SDK.
    i have also ticked under project properties. Project References "FacebookSDK"

    still showing in red.

  • got it YAY

    sorry.

    under Project References -> Android -> Library ( i had to re-Add the SDK there too.)

    thank you again.
  • ArtLeeAppsArtLeeApps Member
    edited March 2014
    Ill get this working ...oneday.

    1) when i clicked the post to Facebook sample. i had an error in the logs. about no ApplicationId was set.
    so i googled and added this to the Manifest

    meta-data android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/app_id"

    Then added the string "app_id" to my strings with the Facebook Id. I got this by creating a new Facebook Developer app.

    2) i built it all. installed it on my android phone. now I'm getting this in the logs, but its like a minute after i clicked the post to Facebook.

    ....im just having a bad run hey. sorry.

    txt
    txt
    errorlog.txt
    7K
  • ar2rsawseenar2rsawseen Maintainer
    hmm, interesting, never seen anything like that
    and all StackOverflow answers point to upgrading facebook sdk.
    Which version are you using?
  • A fresh download from the site uncompress folder "facebook-android-sdk-3.7".

    so version 3.7 id say.
  • This line of code in the sample. (apart from my Facebook Developer Id, is there anything else that needs to change, to replace the strings ?

    facebook:login("", {"basic_info", "user_about_me", "publish_actions", "publish_stream"})
  • I'm using 3.6, no problems - not tried 3.7.

    @ar2rsawseen - are you on 3.7?
    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
  • ar2rsawseenar2rsawseen Maintainer
    Noup, works great with latest SDK 3.7

    @ArtLeeApps do you get the crash on login, or any other specific method?
    You can try sending me the project to ar2rsawseen at gmail dot com
    and I will check ;)
  • crash is when you click your sample text to post on Facebook.
  • mmerikssonmmeriksson Member
    edited April 2014
    Did you get it to work?
    I'm having a similar issue where I cant post to the feed.

    I have written this code in my Gideros project:
    require "facebook"
     
    	facebook:addEventListener(Event.LOGIN_COMPLETE, function()
    		print("login successful")
    	end)
    	facebook:addEventListener(Event.DIALOG_ERROR, function(e)
    		print("dialog error", e.type, e.error)
    	end)
    	facebook:addEventListener(Event.DIALOG_COMPLETE, function(e)
    		print("dialog complete", e.type)
    	end)
    	facebook:addEventListener(Event.LOGOUT_COMPLETE, function()
    		print("logged out")
    	end)
     
            --have a real id in my version
    	local appId = "snip"
     
    	facebook:login(appId, {"basic_info", "user_about_me", "publish_actions", "publish_stream"})
     
    	local link = "website"
    	local picture = "picture"
    	local name = "Game!" 
    	local caption = "My score"
    	local description = "Try to beat my score!"
     
    	facebook:postToFeed({"message",link, picture, name, caption, description})
    Is there anything I'm missing in the lua code?

  • you put it in the array like this {message="hi",link="your website url", ... etc

    Likes: mmeriksson

    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
  • mmerikssonmmeriksson Member
    edited April 2014
    Ok, I changed the last few lines to this instead:
            local fbMessage = "message"
    	local fbLink = "my link"
    	local fbPicture = "picture link"
    	local fbName = "Gravell"
    	local fbCaption = "My score"
    	local fbDescription = "Try to beat my score!"
     
    	facebook:postToFeed({message=fbMessage, link=fbLink, picture=fbPicture, name=fbName, caption=fbCaption, description=fbDescription})
    I have real links in my version but the forum complains if I leave them in.

    I can run the code on my android phone and the prompt comes asking if I accept my app to get permission to facebook. I click yes and then I just get pushed back to my app and the state it was before I pushed the facebook button I have.

    Should facebook:postToFeed open up the facebook app on my phone ? or is there another function that needs to be run?

    -edit
    The Logcat says:
    04-09 <span class="nu0">14</span>:<span class="nu0">15</span>:<span class="nu0">42.887</span>: D<span class="sy0">/</span>FacebookSDK.WebDialog<span class="br0">&#40;</span><span class="nu0">19882</span><span class="br0">&#41;</span>: Webview loading URL: m.facebook.com<span class="sy0">/</span>dialog<span class="sy0">/</span>oauth<span class="sy0">/</span>confirm
    &nbsp;
    04-09 <span class="nu0">14</span>:<span class="nu0">15</span>:<span class="nu0">43.117</span>: D<span class="sy0">/</span>FacebookSDK.WebDialog<span class="br0">&#40;</span><span class="nu0">19882</span><span class="br0">&#41;</span>: Redirect URL: fbconnect:<span class="sy0">//</span>success#access_token<span class="sy0">=</span>CAAUNQW99KBsBAADYzGhzgJUCuhIUZA6q9H4RCG7d1T0JYXfduvUINhuIFMZAc6rHeXfuPBODvPWXIoVZAv3jwBRYoRZBh9ZCwVohGu5AXAcmderlzLf8HM65MuekmLoFlQEMJcM5zTvTovYC650eTsKfJG5UrZBjgHL4bMEmRXu1PPkM4I1YHz<span class="sy0">&</span>expires_in<span class="sy0">=</span><span class="nu0">5183211</span><span class="sy0">&</span>e2e<span class="sy0">=%</span>7B<span class="sy0">%</span>22init<span class="sy0">%</span>22<span class="sy0">%</span>3A1397045741413<span class="sy0">%</span>7D
  • ar2rsawseenar2rsawseen Maintainer
    edited April 2014
    @mmeriksson it means you did not have permission to post, and thus was asked by a facebook app to grant such permission.

    postToFeed does not raise any dialog, it simply posts to your feed, so check your facebook account, maybe you already posted something there ;)

    if you want to show dialog, use:
    dialog("feed", params)

    Likes: mmeriksson

    +1 -1 (+1 / -0 )Share on Facebook
  • mmerikssonmmeriksson Member
    edited April 2014
    Okey. Thank you for explaining, will try that :)
  • Ok, after some searching and log messages in GFacebook and SimpleFacebook I found out that it was my Key Hash that was wrong. So I made a new one and now it works like a charm!

    Likes: ar2rsawseen

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.