Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
share score on facebook — Gideros Forum

share score on facebook

pedroluis5pedroluis5 Member
edited May 2013 in General questions
anyone have any examples of how to share score on facebook and invite friends?
Already implemented the facebook sdk in my application now can take my picture and my name used facebook: graphRequest.
Now I need to find a way to send a score and how to know which of my friends are connected to the application
«1

Comments

  • ar2rsawseenar2rsawseen Maintainer
    @pedroluis5 firstly I think that in that case your facebook app should be in games category, and then it is again a simple graph request something like:
    local score = 10
    local paramaters = {
     score = score,
     fields = "firstname" 
    }
    facebook:graphRequest("me/scores", paramaters,"POST")
  • achimenoachimeno Member
    edited May 2013
    --User info
    if facebook:isSessionValid() then
    	facebook:graphRequest("me")
    end
     
    --Send score
    local score = 99
    if facebook:isSessionValid() then
    	print("Send score to facebook "..score)
    	local paramaters = {
    		score = score,
    		fields = "firstname"	
    	}
    	facebook:graphRequest("me/scores", paramaters,"POST")
    end
     
    --Get scores
    if facebook:isSessionValid() then
    	facebook:graphRequest(conf.facebookAppId.."/scores")
    end
     
    --Invite friends
    local params = {
    	message = "Check out this awesome game"
    }
    facebook:dialog("apprequests", params)
     
    --Callbacks
    facebook:addEventListener(Event.REQUEST_COMPLETE, 
    	function(event) 
    		print("Facebook request complete", event.response)
    		facebook.lastResponse = Json.Decode(event.response)
     
    		if(facebook.lastResponse==true) then
    			print("Request send score")
    		--Request user info
    		elseif(facebook.lastResponse.id) then
    			print("Request user info "..facebook.lastResponse.id)
    			--User info in -->facebook.lastResponse
    		elseif(facebook.lastResponse.error) then
    			print("Error "..facebook.lastResponse.error.message)
    		else
    			print("Scores")
    			--Scores in --> facebook.lastResponse
    		end
    	end)
     
     
    facebook:addEventListener(Event.REQUEST_ERROR,   
    	function(event)
    		print("Facebook error") 
    	end)
     
    facebook:addEventListener(Event.DIALOG_COMPLETE, 
    	function() 
    		print("Facebook dialog complete") 
    	end)
    +1 -1 (+2 / -0 )Share on Facebook
  • @achimeno: To make it look like @ar2rsawseen has done use:
    <_pre lang_=_"lua" >your stuff</_pre>
    removing all _
  • is fantastic how you respond fast .. Thanks guys I'll test these functions. I think my application is not in the category facebook games.

    Tks @achimeno @ar2rsawseen
  • Gideros the player for android already integrated with facebook?
  • ok @ar2rsawseen, today i use the gideros player on iphone to debug my code with facebook...i use many prints. and on android i cant do that
  • ar2rsawseenar2rsawseen Maintainer
    @pedroluis5 theoretically it should work the same on android as in the same code.

    And you can easily create a Gideros Android player, by deleting assets folder inside assets folder in Android project

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • pedroluis5pedroluis5 Member
    edited May 2013
    my app needs post score of user and to do this the app needs this permission...
    request error	5	Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x1d5a9350 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey=(
            {
            body =         {
                error =             {
                    code = 200;
                    message = "(#200) Requires extended permission: publish_actions";
                    type = OAuthException;
                };
            };
            code = 403;
        }
    ), com.facebook.sdk:ErrorSessionKey=<FBSession: 0x1d5a4b30, state: FBSessionStateOpen, loginHandler: 0x0, appID: 132957176893573, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionManualTokenCachingStrategy: 0x1d53f210>, expirationDate: 2013-07-01 21:32:01 +0000, refreshDate: 2013-05-02 23:18:43 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(null)>}
    when try use this
    facebook:authorize({"publish_actions"})
    the facebook login report this

    "an error occurred: the privacy of writing is not specified"

    what happend?

    I think that i not configure very well app on facebook as a game

    Likes: jdbc

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2013
    Here this might help:
    http://stackoverflow.com/a/16163736/2274511

    I was able to fix this by removing the newly added FacebookDisplayName property ( as of FB SDK 3.5) from the *.plist file.

    Opened a bug @ facebook:
  • @ar2rsawseen tks for help ^:)^ . I remove FacebookDisplayName from the .plist and now work.
    I can post and get score of my user.
    Now i will try to get score of my friends..

    tks :D
  • pedroluis5pedroluis5 Member
    edited May 2013
    Hello

    My friend @Emanuel could work with @ar2rsawseen the facebook plugin in android player. but when trying to get my photo returns this error
    {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
    i use this but not work
    facebook:extendAccessTokenIfNeeded()
  • ar2rsawseenar2rsawseen Maintainer
    @pedroluis5 when debugging plugin I've suggested @Emanuel to

    If you comment out the line 57:
    String token = getFBToken();
    in src/com/giderosmobile/android/plugins/facebook/GFacebook.java

    and replace it with this line:
    String token = "";
    You need to reverse it, or better download new GFacebook.java from github if there were any more changes
  • @Emanuel make the change and the same erro still return
    is need remove this line?
    facebook:extendAccessTokenIfNeeded()
  • ar2rsawseenar2rsawseen Maintainer
    @pedroluis5 by the error it seems that there is no token. Can you attach the project and let me check it? :)
  • @ar2rsawseen i send a email to you with the code
  • @ar2rsawseen i need add you as develop of my project..you have a facebook?
  • ar2rsawseenar2rsawseen Maintainer
    @pedroluis5 yes I've received it and can reproduce the error, so I'll look into it;)

    But unfortunately not today, the hockey game starts in an hour, so I'll do that first thing tomorrow ;)

    Likes: nelinho

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    One thing I've noticed though, as some requests are executed correctly, there must be one particular that does not work, I'll try to isolated later
  • @ar2rsawseen tks for great help...do this in your time
  • ar2rsawseenar2rsawseen Maintainer
    Ok I think I got it, after simple, googling, it seems it is a bug in Android SDK, you should use the user ID instead of me value. and I think you should pass parameters as additional table like this:
    facebook:graphRequest("100001081690027/picture", {width = 144, height=144})
    If not I will look further :)
  • SinisterSoftSinisterSoft Maintainer
    I've spoken to a few people about graph and it appears sometimes things don't work as documented. They suggested using parse.com instead - looks like that might be a good idea as facebook have bought them.
    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
    @SinisterSoft looks like someone is selling parse as a plugin more and more :)
  • ar2rsawseenar2rsawseen Maintainer
    Another solution would be to upgrade to Facebook SDK v3, but problem is, that it is completely different, and current Gideros Facebook API (which is based on Facebook SDK v2) is completely incompatible with Facebook SDK v3.
    So
    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
  • SinisterSoftSinisterSoft Maintainer
    That's why parse might be better, as it's now owned by Facebook - it also allows posting, interaction, etc with Twitter.
    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
  • pedroluis5pedroluis5 Member
    edited May 2013
    Tks @ar2rsawseen, @Emanuel make this and now work very well.

    there is still a bug. when we logout the player closes alone
    local paramaters = {		
       type = "normal",
       redirect = "false"
    }
    facebook:graphRequest(ID.."/picture", paramaters,"GET")
    I am using the last version of facebook sdk for IOS 3.5.1

    Do you have facebook sdk 2.0?
Sign In or Register to comment.