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

Facebook documentation incorrect.

24

Comments

  • SinisterSoftSinisterSoft Maintainer
    edited January 2014
    Might be because it still in test mode on Facebooks server, not made it public yet.

    Any examples on how to get friend images, scores, etc?

    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
    edited January 2014
    for friends images, all you have to do is to get friend ids using getFriends method
    and then download each image as one of these sizes replacing {id} with user Id
    https://graph.facebook.com/{id}/picture?type=small
    https://graph.facebook.com/{id}/picture?type=square
    https://graph.facebook.com/{id}/picture?type=normal
    https://graph.facebook.com/{id}/picture?type=large

    And by this description
    http://stackoverflow.com/questions/13143167/facebook-app-getting-scores-from-friends

    get scores should get both user and his friends scores

    But I honestly have not played much with it yet

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • On Facebook dev, there is a section to add your android game. In it it says "Class Name", what should go in here? Also there are switches for 'Single Sign On' and 'Deep Linking'. Should they be on or off ?
    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
  • in my test app Class Name is: com.yourdomain.yourapp.FacebookActivity
    SSO is basically an authentication with facebook, which I think is needed

    Deep linking means that using facebook on mobile device, if user click the link to go to your app page, it will actually open your app (optional if you want) ;)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • Thanks for that, sorted now. I think you should maybe put this in the docs, a screenshot would be good too. :)
    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
  • Hi ar2rsawseen, Just seeing your facebook progress has made my day :) coming from java spring social library, I want to implement facebook logins for a card game to have membership autologins as long as they already login to facebook or is going to login.
    Like how Zynga texas holdem poker, we can login as the game account or login as facebook account where users can access account information like avatar picture, username, name. If you can initiate those functions and released them even as a beta version I would be pleased to actually use it and give you some feedback.
    One other thing, if you could add some assists method of integrating with a non-blocking socket server with odbc functionalities to connect to postgresql or MSSQL. My game will connect to sql database to store data and I am stil confused of how I am going to do that as my knowledge of lua is very new(coming from java/c#).
  • @telostia interesting, but I have never heard about different accounts (facebook account and game account), how does that work, or is there any pointers in the facebook docs?

    And about database. Hmm do you want to connect to remote database?
    Because I don't think there will be any odbc drivers and you would have to implement the protocol yourself through lower level api:
    http://appcodingeasy.com/Gideros-Mobile/Using-LuaSocket-in-Gideros

    And if you just want to locally use database, then on mobile devices there is usually one alternative that seems to be working on all mobile OSes: sqlite
    http://docs.giderosmobile.com/reference/plugin/sqlite3#sqlite3

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited January 2014
    I think you mean 'pages'. There are app pages that can only be created though the facebook dev system. I made the mistake of making a game product page before the setting up the app in facebook, I though I could link to that, but you can't - it has to be an app page - you can't convert a page to an app page apparently either. You can't merge them either - it will error out.

    No documentation on facebook about any of this anywhere - I think it's and evolving system and things are not set in stone.

    Sorted now though - I just renamed the old page, and made a new page through the dev system, did a shout out to everyone who liked the old page to like the new one. :)
    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
  • telostiatelostia Member
    edited January 2014
    @ar2rsawseen The game account I was mentioning was the app account and using facebook account id as key to automatically create an app/game account and to link them up. It has to be linked to a remote database because the accounts would be stored on the backend/server and it uses sql to authorize whos login into the game and distribute the connections. I was just testing noobhub which uses luasocket to achieve the connections to the server and noticed that there isnt much documention nor is the lib complete. Hm. I guess I have to program the server which connects directly to the sql server through jdbc and to also link the facebook lib directly to the server. But I would need some kind of facebook client to connect to the server. How would you go about doing that in gideros?
  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    Maybe it is due to different terms from different environments, or language barrier, but I have a hard time understanding the scheme you want to implement.

    But I think there could be 2 scenarios:
    1) From your Gideros app connect and authenticate user in Facebook
    2) Retrieve user's auth token and pass it to a third party server
    3) Retrieve more information about the user on the server from facebook

    Or
    1) From your Gideros app connect and authenticate user in Facebook
    2) Retrieve user's information from facebook in your app
    3) Pass it to the third party server

    Is any of them correct? :)

    If yes, then first two points can be achieved through Facebook SDK with a plugin made for Gideros
    And the third point completely depends on your server implementation.
    But to communicate with the Gideros app, usually either
    some sort of REST API is used in combination with UrlLoader
    or direct socket connection through Lua Socket

    In both of them I don't have an experience of connecting directly to a databse, but rather creating some sort of layer (as REST API) to use server side technology to connect to the database and pass data to it.
    But I think that is probably what you meant in your post, right? :)

    BTW, what platforms are you targeting? Both Android and IOS?
  • the second scenario would probably be a better choice as you only need to auth facebook once while grabbing as much information from the user and to let the app talk to the server to verify if the account matches with the app account stored on the sql database. Does the facebook plugin you are working on can authenticate facebook accounts for android and IOS? because that's what i'm targeting. That's one of the main point I chose to use gideros-for the multiplatform feature. Android/java would be an easier choice but I'd have to rewrite the entire client in obj-c for the IOS as well which isn't a good idea imo.

    REST api would be too laggy for a realtime card game based on numerous recommendations so I would prefer through lua socket which connects to a dedicated server. The server uses xml binding to parse the messages from the clients to the server but the problem is getting that facebook authentication. Maybe I should parse it through xml binding to the server?

    Atm I got the server code in Java which connects directly with postgresql though I haven't implemented facebook yet but if the authentication need only be on the client's end that would make things alot easier.
  • @telostia well for both IOS and Android Facebook (but for older SDK are right now available with the Gideros installation)
    or check attachement to this post if you are missing some plugins on your Mac:
    http://www.giderosmobile.com/forum/discussion/4340/new-version-gideros-2014-01/p1

    And yes they would authenticate you through facebook and allow retrieving information
  • telostiatelostia Member
    edited January 2014
    which version of facebook sdk is old? sorry, did you mean the IOS is using the new facebook sdk and the android is stil using the old sdk?
  • @telostia no i mean both ios and android currently use Facebook SDK 2.x, you can find them inside Gideros installation folder All Plugins/Facebook
    I think ios still maintains compatability headers with the old version, but for android to work, you would need to use older SDK from here: https://github.com/ar2rsawseen/GiderosFacebookAndroidPlugin

    You can find more info about the plugin here:
    http://docs.giderosmobile.com/reference/plugin/Facebook#Facebook
  • There is an easy way to get the scores / users playing your game:

    facebook:get("/"..facebookAppID.."/scores",{limit=5000})

    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
  • @ar2rsawseen using your api, how to you know your own facebook id?
    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
  • In order to get pictures there needs to be some kind of easy decode system as it returns 'facebook non json' in the middle of some json.

    facebook:get("/"..user.id.."/picture",{type="small"})

    returns

    /xxxxxx/picture {"FACEBOOK_NON_JSON_RESULT":"����\u0000\u0010JFIF\u0000\u0001\u0002\u0000\u0000\u0001\u0000\u0001\u0000\u0000��\u0000\u0004*\u0000��\u0002\u001cICC_PROFILE\u0000\u0001\u0001\u0000\u0000\u0002"}

    (I've replaced the user id with xxxxxx).
    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
    edited February 2014
    aha, now I see about the picture, here is how I get the pictures:
    --to check if file exists
    function file_exists(name)
       local f=io.open(name,"r")
       if f~=nil then io.close(f) return true else return false end
    end
     
    -- to store ids of FB users I need to queue photos for
    fbPhotoQueue = {}
     
    -- to process photo queue
    function fbProcessPhoto()
    	--if there is something in queue
    	if #fbPhotoQueue > 0 then
    		--get id
    		local id = table.remove(fbPhotoQueue)
    		--construct url
    		local url = "<a href="https://graph.facebook.com/"..id.."/picture?type=square&quot" rel="nofollow">https://graph.facebook.com/"..id.."/picture?type=square&quot</a>;
    		--make UrlLoader call
    		local loader = UrlLoader.new(url)
     
    		loader:addEventListener(Event.COMPLETE, function(event)
    			print("complete", id)
     
    			-- try to save it in file as png
    			local out = io.open("|D|"..id..".png", "wb")
    			out:write(event.data)
    			out:close()
     
    			-- resave it as png, because image might have been jpeg
    			--but media plugin will automatically convert it to png
    			-- pcall because it might be other unsupported format
    			pcall(function()
    				local media = Media.new("|D|"..id..".png")
    				media:save()
    				media = nil
    			end)
    		end)
    		-- we can ignore errors photos and try them again on next sync
    		loader:addEventListener(Event.ERROR, function()
    			print("error", id)
    		end)
    		--call to process next photo
    		fbProcessPhoto()
    	end
    end
    Then when I try to load the pictures, I check if I have the correct picture for user, or try to load the default one
    function loadFBphoto(id)
    	local texture
    	-- if picture exists
    	if file_exists("|D|"..id..".png") then
    		local success
    		success, texture = pcall(Texture.new, "|D|"..id..".png", true)
    		-- if I was able to load it (has correct format)
    		if not success then
    			texture = nil
    		end
    	end
    	-- if no texture, take default pic
    	if not texture then
    		texture = Texture.new("images/default.png", true)
    	end
    	return Bitmap.new(texture)
    end
    Now all you need is to get information about player and then get scores and process pictures
    facebook:addEventListener(Event.REQUEST_COMPLETE, function(e)
    	-- getting information about player
    	if e.type == "me" then
    		local data = json.decode(e.response)
    		print(data["id"]) -- player id
    		prinydata["name"], true)
    		-- getting scores
    		facebook:getScores()
    	elseif e.type == appID.."/scores" then
    		local data = json.decode(e.response)
    		for i = 1, #data["data"] do
    			-- if I don't have a pic yet
    			if not file_exists("|D|"..data["data"][i].user.id..".png") then
    				-- insert to queue
    				table.insert(fbPhotoQueue, data["data"][i].user.id)
    			end
    			--here you can also retrieve your players score
    		end
    		--if there is anything in queue, start processing it
    		if #fbPhotoQueue > 0 then
    			fbProcessPhoto()
    		end
    	end
    	print("request complete", e.type, e.response)
    end)
     
    --get information about user upon login
    facebook:addEventListener(Event.LOGIN_COMPLETE, function()
    	facebook:getProfile()
    end)
     
    --login to facebook
    facebook:login(appID, permissions)

    Likes: SinisterSoft

    +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
  • gimgim Member
    edited February 2014
    Parse Facebook login (parse.com/docs/rest#users-linking) requires access_token and expiration_date fields. Both are provided as in Gideros Facebook Android Plugin 0.1 but no more exists at version 0.2. How can I retrieve them?

    By the way, I am curious about your network library design paradigm: event-based asynchronous pattern; it assumes there is one and only one asynchronous request at once. For disambiguity, task-based anychronous pattern is preferred in my code like the wrapper following:
    local requestQueue = {}
     
    local function requestDispatcher(event)
        local callback, data
        for i, v in ipairs(requestQueue) do
            callback, data = v[4], v[5]
        end
        table.remove(requestQueue, 1)
        if callback then
            if data then callback(data, event) else callback(event) end
        end
        for i, v in ipairs(requestQueue) do
            local path, method, parameters = v[1], v[2], v[3]
            facebook[method](facebook, path, parameters)
            break
        end
    end
     
    facebook:addEventListener(Event.REQUEST_COMPLETE, requestDispatcher)
    facebook:addEventListener(Event.REQUEST_ERROR, requestDispatcher)
     
    local function fbRequest(path, method, parameters, callback, data)
        local any
        for i, v in ipairs(requestQueue) do
            any = true
            break
        end
        table.insert(requestQueue, {path, method, parameters, callback, data})
        if not any then facebook[method](facebook, path, parameters) end
    end
  • @gim ok was not aware something like that was needed, will include in the next version

    and about dispatching, yes I have the same problem currently, while working on a test app for the facebook, so will see how this can be solved, but currently don't have a proper solution :)
  • I tried to delete the current set of scores - to reset the game.

    facebook:delete("/"..facebookAppID.."/scores")

    But I get an error:
    request error: /..................../scores (#15) This method must be called with an app access_token.
    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 most probably you need some kind of specific permission to do that
    If only for testing purpose, I would go and try to do that at their graph explorer :)

    https://developers.facebook.com/tools/explorer
  • Thanks. :)
    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
  • Nah, still can't get it to work - I've seen others have the same problem - maybe they never implemented it - but documented it. ;)
    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
    One question about invite friends not playing the game.

    If I send a Facebook dialog "apprequest" to invite some of my friends, the question is ¿how can I know if this request has been accepted later?

    I am not sure about how to implement it.

    For example, if invitation is accepted then you will receive a new life or some coins.
  • ar2rsawseenar2rsawseen Maintainer
    Here is more on app requests:
    https://developers.facebook.com/docs/games/requests

    Basically this is implement through server side of your app
    by redirecting user to a specified url, etc
  • jdbcjdbc Member
    edited March 2014
    I will read http://www.9lessons.info/2012/07/facebook-invite-friends-api.html

    It seems we must define a web canvas URL.

    Anyway is it possible to get request_id from Event.DIALOG_COMPLETE event and store it in some place to check accepted invitations.
Sign In or Register to comment.