Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Facebook Android Plugin - Page 2 — Gideros Forum

Facebook Android Plugin



  • EmanuelEmanuel Member
    @ar2rsawseen when you translate facebook plugin for android to facebook 3.0.1 sdk version?
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    @Emanuel unfortunately the problem is, that Facebook SDK v3 is completely different, and current Gideros Facebook API (which is based on Facebook SDK v2) is completely incompatible with Facebook SDK v3.
    1) it would break existing apps
    2) there is a need of time and workforce to do that, both now are dedicated to more urgent matters

    But that might change if someone is willing to wrap Facebook SDK in Java and IOS wrappers with similar API to current :)
  • EmanuelEmanuel Member
    edited May 2013
    @ar2rsaween do you have facebook sdk v2 to send me, because I dont found to download. My email emanuelperpeto @ gmail dot com
  • ar2rsawseenar2rsawseen Maintainer
    @Emanuel last time I checked Facebook SDK v3 also includes deprecated v2 methods, so it should work with it. Sorry if I did not make it clear :)
  • fxonefxone Member
    edited May 2013
    I have some issue with FB @ar2rsawseen's plugin integration at Android device. Under Eclipse everything looks fine, there is no errors. I can sign apk properly, I can also install apk on device, with no problem. But:
    - Just after running app with @ar2rsawseen's default example, when it's trying to connect with fb, I have an info about error: "Invalid android key parameter. The key [there is a key 28 chars] does not match any allowed key...[!]
    honestly I have six variations of these keys: with "=" on the end, from 28 to 31 chars etc... followed by different advices like for example from here:
    I have now 8 various hash keys and I'm going crazy @-) - I've spent already 12 hours on it... Please help me!
    Windows 7 x64 /Android 2.2 Froyo.

    ps. of course I've changed appId..
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    @fxone I used this code to check what has key really was:
    only replace it with your package name
    PackageInfo info;
    try {
    	info = sActivity.get().getPackageManager().getPackageInfo("com.yourdomain.yourapp", PackageManager.GET_SIGNATURES);
    	for (Signature signature : info.signatures) {
    		        MessageDigest md;
    		        md = MessageDigest.getInstance("SHA");
    		        String something = new String(Base64.encode(md.digest(), 0));
    		        //String something = new String(Base64.encodeBytes(md.digest()));
    		        Log.e("hash key", something);
    } catch (NameNotFoundException e1) {
    	    Log.e("name not found", e1.toString());
    } catch (NoSuchAlgorithmException e) {
    	    Log.e("no such an algorithm", e.toString());
    } catch (Exception e) {
    	    Log.e("exception", e.toString());
    and then you should input this hash key in the facebook.com in your Android app settings.

    Likes: fxone

    +1 -1 (+1 / -0 )Share on Facebook
  • fxonefxone Member
    edited May 2013
    @ar2rsawseen Thanks! ok finally full success: it was one from my eight key hashes, but unfortunately I set too much on fb site yesterday evening :D it also works properly for me: http://stackoverflow.com/a/7564008
  • fxonefxone Member
    edited June 2013
    Hi @ar2rsawseen! Ok finally I can post and get scores, feeds to fb etc. But I've noticed some problem: when I beat a record during one session, it's received some error in lua:
    start.lua:48: attempt to index field 't' (a boolean value)
    stack traceback:
    	start.lua:48: in function <start.lua:26>
    in start.lua my code looks like:
    if facebook:isSessionValid() then
    local t = Json.Decode(event.response) 
    local Text = TextField.new(nil, "You have"..t.data[1].score.." scores!")
    There is no error at first attempt of:
    only at second when I change the scene from level.lua to start.lua page only after posting a new record..

    thanks in advance!

  • ar2rsawseenar2rsawseen Maintainer
    @fxone could you please tell me what are the contents of event.response after second request?

    Likes: fxone

    +1 -1 (+1 / -0 )Share on Facebook
  • fxonefxone Member
    edited June 2013
    @ar2rsawseen right, second request from level.lua:
    	if facebook:isSessionValid() then
    	print("Send score to facebook "..score)
    	local parameters = {
    		score = score,
    		fields = "firstname"	
    	facebook:graphRequest("me/scores", parameters,"POST")
    	local response=Json.Decode(event.response)
            print("event response", response)
    ps. ok I got it one sec... :)
  • fxonefxone Member
    edited June 2013
    @ar2rsawseen contents of event.response after second request from level.lua (as above) is:
    [edited Sorry, I've checked again]
    event response	nil
    event response	true

  • fxonefxone Member
    edited June 2013
    @ar2rsawseen is this a bug? similiar to: http://stackoverflow.com/questions/15988268/calling-functions-on-required-modules-in-lua-gives-me-attempt-to-index-local
    I've tried also some Corona solution, looking like (firstly removed
    from top):
    local json=require("Json") 
    local t=json.Decode(event.response)
    but it's still the same:
    attempt to index field 't' (a boolean value)
    I know, it's too late :) Let's get back on track tomorrow! ;)
  • fxonefxone Member
    edited June 2013
    @ar2rsawseen sorry for annoying asking since yesterday, but is this possible to remove listeners for:
    from facebook plugin? It looks like it holds value and ignores new attempt of request...
  • ar2rsawseenar2rsawseen Maintainer
    edited June 2013
    @fxone yes, basically what happens is that retrieving score returns json with all the data, but submitting score returns value true.
    So what you would need to do is to expect any kind of result. Probably the easiest way is to check
    if e.response ~= "true" then
        local t = Json.Decode(e.response)
        if t.data then
            --have your score result here
        elseif e.response == "false" then
            --could not submit the score
    Unfortunately there is no direct way to determine to which app requests we got the response for, at least current Facebook SKD does not provide it. So your best bet is to try to determine it based on the contents of response.

    So right now there is only one REQUEST_COMPLETE event and you should try to combine everything in one event call if you can, like here handling both retrieving and submitting scores.

    Likes: fxone

    +1 -1 (+1 / -0 )Share on Facebook
  • fxonefxone Member
    edited June 2013
    @ar2rsawseen you are great! :-bd I got stuck, but finally it solved, thank you! it's working like a charm now :D
  • Hi all,

    Help Please !!.. ive been staring at this for hours, ive followed the facebook setup, and imported and removed the Facebook SDK a few times as i cant get rid of these errors.

    i have 2 screen shots showing each of the SDK projects with errors, and the build path looks ok.

    also the reference to "GFacebook.fb.authorizeCallback(requestCode, resultCode, data);" has an error on "GFacebook".

    Pleaseeee im running out of the bits of hair i had left.

  • ar2rsawseenar2rsawseen Maintainer
    @ArtLeeApps have you imported com.giderosmobile.android.plugins.facebook.GFacebook into your main activity? :)

    I found that it also seemed to work when both Facebook SDK and your Gideros Facebook project folders are in the same workspace (basically in the same relative folder)

    You must not add facebooksdk.jar but rather treat whole FacebookSDK project as a library and install it as described in installation instructions. As far as I know there are no more simple .jar files in facebook
  • ar2rsawseenar2rsawseen Maintainer
    I've also attached Facebook SDK I used to develop plugin to the first post and I'm pushing it to github
  • @ar2rsawseen thank you,
    in the process of adding Facebook i imported the folder into my app, resulting in the facebook stuff overwriting the manifest and stuff.. so ive just done a full Gideros export, re-added, AdMob, Billing, and Facebook.. (and made notes on what i did )

    Anyway, after moving the Facebook SDK folders to my workspace, and then importing that into eclipse, then added it as a Library to my project it was happy.
    all the sample facebook apps had issues, but i worked out, i had to add (android-support-v4.jar) as an external Jar to make them happy too :)

    now its 2am here in the land of OZ so ill start trying to setup the bits to get my Facebook APP ID tommorrow, so i can post from my app... finally !

    Thanks again :-bd
  • Hi @ar2rsawseen

    When the code get to the "Authorize()"
    it goes to a Web page not found.
    and eclipse has this in the logs.....

    08-05 21:55:47.642: W/dalvikvm(16663): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
    08-05 21:55:47.642: W/dalvikvm(16663): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
    08-05 21:55:47.652: I/dalvikvm(16663): Could not find method android.support.v4.content.LocalBroadcastManager.getInstance, referenced from method com.facebook.Session.postActiveSessionAction
    08-05 21:55:47.652: W/dalvikvm(16663): VFY: unable to resolve static method 360: Landroid/support/v4/content/LocalBroadcastManager;.getInstance (Landroid/content/Context;)Landroid/support/v4/content/LocalBroadcastManager;
    08-05 21:55:47.652: D/dalvikvm(16663): VFY: replacing opcode 0x71 at 0x0009
    08-05 21:55:47.652: D/dalvikvm(16663): VFY: dead code 0x000c-0010 in Lcom/facebook/Session;.postActiveSessionAction (Ljava/lang/String;)V
    08-05 21:55:47.812: D/dalvikvm(16663): GC_CONCURRENT freed 618K, 46% free 3483K/6407K, external 2K/514K, paused 3ms+11ms
    08-05 21:55:47.852: D/MediaPlayer(16663): pause() in
    08-05 21:55:47.862: D/MediaPlayer(16663): pause() out
    08-05 21:55:47.872: D/AudioTrack(16663): Audio Track already stopped
  • @ArtLeeApps I think it means you need to upgrade your facebook app on your mobile device or something like that.
  • @ar2rsawseen your a magician ! =D>

    - That now creates the feed for the user to "share".

    1) is there a nicer way of handling an older version of facebook than to crash ? like if it fails to authorise show a dialog to the user ?

    2) is there a way to know if the user "shared" or "cancelled". The reason i ask is, i am rewarding the user with a star if they post..

    then ill let the facebook thing rest :)

    Dislikes: DRS

    +1 -1 (+0 / -1 )Share on Facebook
  • 1) Unfortunately not, that is how facebook implemented their app, they did not leave an option to fallback, because it can only be determined within their own webview in facebook app. And it sucks.
    2) most probably you could check usertimeline (or the wall) to see if the message is really there. You should check Facebook graph API for more info on this one ;)
  • HI @ar2rsawseen... i suppose we cant post without the user clicking "Share".
    just a direct post in the background, if the user is logged in of course.
  • Ah would these be the clue..


    if i listen for CANCEL or COMPLETE and only award them if "COMPLETE" ?

    (i cant test the theory till i get home from work "dammit"... even if i remote desktop to home i cant plug my phone in to test it... lol
    ill need to set up a permanent phone, plugged into my home laptop, and a remote Camera. remote desktop to home, compile and watch my phone on the camera... but till then !!! :) )

  • @ArtLeeApps could be
    Also it most probably is possible to post something without the dialog.
    Basically everything what is available with graph api is available to the plugin:
    https://developers.facebook.com/docs/reference/api/ ;)
  • Which is the best version of this plugin - the github version or the labs version (they both have slightly different GFacebook.java files).

    I also get this error: - GFacebook cannot be resolved

    I've attached a screenshot, you should be able to see that the Facebook SDK has been installed properly (it's the SDK you provide, not the latest version from Facebook).
    09-08-2013 19-55-45.png
    1492 x 432 - 105K
    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!).
  • ar2rsawseenar2rsawseen Maintainer
    edited August 2013
    Ah that might happen when you manage 3 or 4 different repositories with the same code :)
    Now let me check.

    And that line that gives an error might be obsolete, because I think @atilim now passes the onActivityResult directly to the plugin, let me check that also ;)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • That would be good. :)
    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!).
  • Hmm they seemed to be similar, but just in case I've synced all the repos with internal repo.

    And yes, there is no need to call GFacebook from ActivityResult anymore, updated the instructions accordingly ;)

    Likes: SinisterSoft

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