Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Facebook documentation incorrect. - Page 3 — Gideros Forum

Facebook documentation incorrect.

13

Comments

  • jdbcjdbc Member
    How can I replace facebook:isSessionConnected() with facebook:getAccessToken() == "" in this new version?

    I was using isSessionConnected previous Facebook SDK to check if user was connected and do not show the login button. But now the first time it returns "" as access token.
  • I just put a facebook icon down and if there was a previous login, do a login - I then hide the icon on the login completed event. If the icon is pressed then I have a go logging in and set the setting to try login on startup next time. In options I have a login in not logged in and a logout if logged in (the logout will clear the auto login setting).
    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
  • jdbcjdbc Member
    edited March 2014
    I just put a facebook icon down and if there was a previous login, do a login - I then hide the icon on the login completed event. If the icon is pressed then I have a go logging in and set the setting to try login on startup next time. In options I have a login in not logged in and a logout if logged in (the logout will clear the auto login setting).
    My problem is how to check if there was a previous login when app starts. If I do facebook:login() and user is not connected it will show facebook login page. But I prefer that user push login button if he is not connected.

    I assume you use datasaver.lua or similar functionality to store settings on disk then and to know if next time go logging must be done on startup.

  • SinisterSoftSinisterSoft Maintainer
    edited March 2014
    After the facebook icon is pressed and logon successful then save a file called facebook with a value of one. Check if 1 at startup then log on automatically.
    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
  • I don't use datasaver myself I use this:

    local file=io.open("|D|"..en("facebook.txt"),"w+")
    if file then
    file:write("1")
    file:close()
    end

    The en("xxxx") just encrypts the filename - so they don't know what is going on if they try look at the files.

    Likes: jdbc

    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
  • jdbcjdbc Member
    edited April 2014
    What about provide a facebook:getExpirationDate() but returning String format with format as "2012-02-28T23:49:36.353Z".

    It is possible to provide Parse linking integration (https://parse.com/docs/rest#users-linking)? I was testing Parse using facebook users.

    I guess changes on java code will be something like:
    public static long getExpirationDateAsString(){
    		if(Session.getActiveSession() != null)
    			return (long)Session.getActiveSession().getExpirationDate();
    		return 0;
    	}
  • ar2rsawseenar2rsawseen Maintainer
    @jdbc latest version already provides facebook:getAccessToken() and facebook:getExpirationDate()
    on expriation date returned as number and can be formated after in lua using os.date
    http://www.lua.org/pil/22.1.html

    Likes: jdbc

    +1 -1 (+1 / -0 )Share on Facebook
  • jdbcjdbc Member
    edited April 2014
    @jdbc latest version already provides facebook:getAccessToken() and facebook:getExpirationDate()
    on expriation date returned as number and can be formated after in lua using os.date
    http://www.lua.org/pil/22.1.html
    I was linked facebook and parse user using authData as Parse documentation explains. This is my code:
    ParseAPI = Core.class()
     
    local base_url = "<a href="https://api.parse.com&quot" rel="nofollow">https://api.parse.com&quot</a>;
    local headers = {
    					["X-Parse-Application-Id"] = "Your Parse App Id",
    					["X-Parse-REST-API-Key"] = "Your REST API Key",
    					["Content-Type"]  = "application/json"
    					}
     
    require "json"
     
    -- Parse login using authData
    function ParseAPI.login()
    	local url = base_url.."/1/users"
    	local method = UrlLoader.POST
     
    	local data = {}
    	local authData = {}
    	local token = {
    					id = social.userid,
    					access_token = social.accessToken,
    					expiration_date = "2014-06-01T17:44:46.000"
    					}
     
    	authData.facebook = token
    	data.authData = authData
    	local body = json.encode(data)
     
    	print("body", body)
     
    	local loader = UrlLoader.new(url, method, headers, body)
     
    	local function onComplete(event)
    		print("onComplete", event.data)
    	end
     
    	local function onError()
    		print("onError")
    	end
     
    	local function onProgress(event)
    		print("onProgress: ")
    	end
     
    	loader:addEventListener(Event.COMPLETE, onComplete)
    	loader:addEventListener(Event.ERROR, onError)
    	loader:addEventListener(Event.PROGRESS, onProgress)
     
    end
    Next I will try to convert facebook:expirationDate() to some String like ""2014-06-01T17:44:46.000"
  • jdbcjdbc Member
    This is my function to convert facebook:getExpirationDate() to Parse API format:
    -- Convert date to format "2014-06-01T15:06:46.000Z"
    local function convertDate(string_date)
     
    	local pattern = "(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)"
    	local year, month, day, hour, minute, sec = string_date:match(pattern)
     
    	local converted	= os.time( {year = year, 
    								month = month, 
    								day = day, 
    								hour = hour, 
    								min = minute, 
    								sec = sec}
    								)
     
    	--print ("convertedTimestamp", converted )
    	local formated_date = os.date("!%Y-%m-%dT%H:%m:%S.000Z", converted)
     
    	return formated_date
    end
  • gimgim Member
    @jdbc if you use LuaDate, it's easy to get ISO 8601 formatted date:
    require "date"
     
    local expirationDate = date(facebook:getExpirationDate()):fmt("${iso}")
  • I follow all steps and I got this on android's Logcat:

    04-11 00:27:27.141: E/AndroidRuntime(31511): java.lang.NullPointerException
    04-11 00:27:27.141: E/AndroidRuntime(31511): at com.giderosmobile.android.plugins.facebook.GFacebook.login(GFacebook.java:89)

    Did I miss something?

  • ar2rsawseenar2rsawseen Maintainer
    Hello @anunesezlearn can you post what you have exactly at GFacebook.java line 89?
    Because it might have changed from version to version :)
  • public static void login(String appId, Object[] permissions){
    if(permissions != null)
    PERMISSIONS = (String[])permissions;
    SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
    .setAppId(appId)
    .setPermissions(PERMISSIONS)
    .build();
    SimpleFacebook.setConfiguration(configuration);

    //89--> sActivity.get().runOnUiThread(new Runnable() {
    @Override
    public void run() {
    sfb.login(new LoginCallback());
    }
    });
    }
  • anunesezlearnanunesezlearn Member
    edited April 2014
    and line 49:
    sActivity = new WeakReference(activity);
  • ar2rsawseenar2rsawseen Maintainer
    Hmm thats what I had here also
    But it does not make any sense.
    Currently I don't know a situation where there won't be an activity in weakholder.

    Either you call login even before application onCreate was called, which is impossible
    or call login after application was destroyed. Which is also impossible

    :D

    Is there anything specific in your lua code?
  • No, right now, this is it. Thanks
  • ar2rsawseenar2rsawseen Maintainer
    @anunesezlearn ah I see, it could be possible if, you did not include GFacebook as external class in main activity, thus it does not receive the reference to activity :)

    Do you have a something like:
    static private String[] externalClasses = {
    	"com.giderosmobile.android.plugins.facebook.GFacebook",
    };
    in your main activity file?
  • Perfect, I did not include GFacebook as external class, now it is working, thanks.
  • This looks like it could be useful with the scoring system to taunt the users friends who are also playing that you just past their score...

    https://developers.facebook.com/blog/post/2012/08/21/bringing-mention-tagging-to-open-graph/
    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
    Yes complete open graph object support is something that is not yet supported and I'm thinking about what better implementation could be

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • I'm sure though I could do this with the existing code. It was just an idea for others to do the same. :)
    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
  • jdbcjdbc Member
    edited May 2014
    I have tried to submit a request "me/invitable_friends":
    facebook:get("me/invitable_friends")
    but I got a error message: (#12) invitable_friends requires version v2.0 or higher

    Is this feature provided?

    I assume this is a very important feature for viral marketing using Facebook friends.
  • ar2rsawseenar2rsawseen Maintainer
    @jdbc if you download the latest facebook version from Gideros Labs, it should support Graph API 2.0
  • jdbcjdbc Member
    edited May 2014
    @jdbc if you download the latest facebook version from Gideros Labs, it should support Graph API 2.0
    I have tested with Gideros Facebook 0.3, I will try with version 0.6

    It seems some behaviour have been changed in Graph API 2.0. For example when you call to facebook:getFriends(), it only returns friends using game. Previous Graph API version returns all your friends.

    I need to use invite_friends feature to submit invitations between friends, two days of Animal Wild Rescue and 600 downloads on IOs should become x4 using invitation with gifts.

    i attach my lua code for Facebook social integration
    lua
    lua
    social.lua
    7K
  • jdbcjdbc Member
    edited May 2014
    After updating to version 0.6, I got the error message when I execute:
    facebook:get("me/invitable_friends")
    (#15) This method is only accessible to Games on Facebook.com - please set a Canvas URL in your app's settings: https://developers.facebook.com/apps/397502363723392/settings

    I have configured my app as Android in settings web page.
  • ar2rsawseenar2rsawseen Maintainer
    @jdbc I haven't used that api yet, but it seems it is not for mobile platforms yet:
    https://developers.facebook.com/docs/games/invitable-friends/v2.0
    The invitable_friends API is only available for games that have a Facebook Canvas app implementation using version 2.0 of the Graph API.
    What you mean I think is actually app requests:
    https://developers.facebook.com/docs/games/requests/v2.0
  • jdbcjdbc Member
    edited May 2014
    If I use
    local params = {
    			title = appName.." request",
    			message = "Check out this awesome app",
    		}
     
    		facebook:inviteFriends(params)
    I can invite friends with a multiselector "apprequest"

    Anyway I do not know how to manage Event.DIALOG_COMPLETE callback to retrieve Facebook userid's in order to know how many and which friends have been invited.
  • ar2rsawseenar2rsawseen Maintainer
    edited May 2014
    @jdbc yes unfortunately now facebook prohibits that.
    You can only get info about users that use your app and they ids are will be only your app specific (you won't get normal ids anymore, only some generated once that will be specific to your app, not across all apps), so until someone joined your app, they actually have no ID.

    Quoting:
    User IDs are now scoped to the calling app and can't be used in other apps.
  • ar2rsawseenar2rsawseen Maintainer
    But with app requests procedure is as follows

    You need to read all app requests for user upon login
    You need to delete each app request after processing it, so it won't be processed again.

    So existing user sends an app request to none approved user. It works as invite. You can provide the message as Invite you blabla. And set data field to some value as invite, so you would know this request is to invite.

    Once the none approved user joins your app, you read its app requests, and you see that existing user sent him a request with data as invite. Then you go credit this user for inviting and delete this app request.
    If multiple users have invited this new user, you either credit all of them or compare created_time field to know who was the first.

    Same thing with sending lives and hearts or bonuses to each other.

    User sends other user a heart or a bonus, you store all the data you need in data field (up to 255 characters) and the when other user logs in, check the requests and display the message, accept, delete, ignore.
    On accept credit the bonus to user and offer to send one back and delete request
    On delete simply delete request
    On ignore, do nothing and same request will be displayed next time you load the user or on push of specific button, etc

    Likes: jdbc

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    I'm using your new lib though - I get exactly the same IDs as I did before - not new iDs specifically for the app. Or is this just new users of the app?

    The data stuff looks good. You need more tutorials with the labs libs.
    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
Sign In or Register to comment.