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
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)
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
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
@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?
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 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
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
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
aha, now I see about the picture, here is how I get the pictures:
--to check if file existsfunction file_exists(name)local f=io.open(name,"r")if f~=nilthenio.close(f)returntrueelsereturnfalseendend-- to store ids of FB users I need to queue photos for
fbPhotoQueue ={}-- to process photo queuefunction fbProcessPhoto()--if there is something in queueif #fbPhotoQueue >0then--get idlocal id =table.remove(fbPhotoQueue)--construct urllocal url ="<a href="https://graph.facebook.com/"..id.."/picture?type=square"" rel="nofollow">https://graph.facebook.com/"..id.."/picture?type=square"</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 existsif file_exists("|D|"..id..".png")thenlocal success
success, texture =pcall(Texture.new, "|D|"..id..".png", true)-- if I was able to load it (has correct format)ifnot success then
texture =nilendend-- if no texture, take default picifnot texture then
texture = Texture.new("images/default.png", true)endreturn 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 playerif e.type=="me"thenlocal data = json.decode(e.response)print(data["id"])-- player id
prinydata["name"], true)-- getting scores
facebook:getScores()elseif e.type== appID.."/scores"thenlocal data = json.decode(e.response)for i =1, #data["data"]do-- if I don't have a pic yetifnot file_exists("|D|"..data["data"][i].user.id..".png")then-- insert to queuetable.insert(fbPhotoQueue, data["data"][i].user.id)end--here you can also retrieve your players scoreend--if there is anything in queue, start processing itif #fbPhotoQueue >0then
fbProcessPhoto()endendprint("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)
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
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 ={}localfunction requestDispatcher(event)local callback, data
for i, v inipairs(requestQueue)do
callback, data = v[4], v[5]endtable.remove(requestQueue, 1)if callback thenif data then callback(data, event)else callback(event)endendfor i, v inipairs(requestQueue)dolocal path, method, parameters = v[1], v[2], v[3]
facebook[method](facebook, path, parameters)breakendend
facebook:addEventListener(Event.REQUEST_COMPLETE, requestDispatcher)
facebook:addEventListener(Event.REQUEST_ERROR, requestDispatcher)localfunction fbRequest(path, method, parameters, callback, data)local any
for i, v inipairs(requestQueue)do
any =truebreakendtable.insert(requestQueue, {path, method, parameters, callback, data})ifnot any then facebook[method](facebook, path, parameters)endend
@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
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
Comments
Any examples on how to get friend images, scores, etc?
https://deluxepixel.com
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
https://deluxepixel.com
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
https://deluxepixel.com
Likes: SinisterSoft
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#).
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
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.
https://deluxepixel.com
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?
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.
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
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
facebook:get("/"..facebookAppID.."/scores",{limit=5000})
https://deluxepixel.com
https://deluxepixel.com
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).
https://deluxepixel.com
Likes: SinisterSoft
https://deluxepixel.com
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:
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
facebook:delete("/"..facebookAppID.."/scores")
But I get an error:
request error: /..................../scores (#15) This method must be called with an app access_token.
https://deluxepixel.com
If only for testing purpose, I would go and try to do that at their graph explorer
https://developers.facebook.com/tools/explorer
https://deluxepixel.com
https://deluxepixel.com
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.
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
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.