Hi,
I have made a function to do REST call to my home-made service:
this is the function
function platform_call(func,params,callback)
local headers = {
["Authorization"] = "Basic",
["Content-Type"] = "application/x-www-form-urlencoded",
}
local method = UrlLoader.POST
local body = params
local url = "<a href="http://192.168.1.10:8080/sta/index.php/"..func" rel="nofollow">http://192.168.1.10:8080/sta/index.php/"..func</a>
local loader = UrlLoader.new(url, method, headers, body)
local function onComplete(event)
local h = Json.Decode(event.data)
if h==nil then h={} end
if callback then callback(h) end
end
local function onError()
spinner:close()
local alertDialog = AlertDialog.new("Error", "Network error!", "Ok")
alertDialog:show()
end
loader:addEventListener(Event.COMPLETE, onComplete)
loader:addEventListener(Event.ERROR, onError)
end |
so i can call a REST api with a callback in this way:
platform_call("challenge/getChallenges","player="..gameSaved.user,
function(response)
if response.success then
print("TOTALE DUELLI "..table.getn(response.challenges))
spinner:close()
else
print("errore"..response.error)
end
spinner:close()
end) |
But how can I make my own function to have a callback when i do a facebook call? I have a global object "facebook" and a global event REQUEST_COMPLETE...:
require ("facebook")
facebook:setAppId("xxx");
facebook:authorize();
facebook:graphRequest("xxx/scores")
facebook:addEventListener(Event.REQUEST_COMPLETE, function(e)
etc etc etc
end) |
Comments
for facebook event Event.REQUEST_COMPLETE is already a callback, where you can make any call where ever you want.
So i need multiple async calls all with its own callback. My idea is to do a UserPicture class and in The init do The rest call And so download And show The picture but with a inique global callback i can't know what picture i m downloading...
Damn android keyboard sorry for The english.
https://play.google.com/store/apps/developer?id=Arcadia Solutions
Yes this is the limitation of Facebook SDK we are using (actually I have not checked if the same is on the Facebook 3.0 SDK or not)
For now, only solution seems to be to get the images one by one.
Request first one, retrieve it in REQUEST_COMPLETE, and request next one there.
That way you would always know which one's image you are currently requesting.
Dislikes: duke2017
https://play.google.com/store/apps/developer?id=Arcadia Solutions
this is the url:
https://graph.facebook.com/USER_ID/picture
but that url do a redirect to the effective picture and so if i use the standard UrlLoader to save the picture i can't know the image extention.
https://play.google.com/store/apps/developer?id=Arcadia Solutions
But thats actually strange because many folks are saying that api only returns jpg photos and I have seen many developers rely on it.
But you are right, it does seem to return gif and even png for some images
|D|100006740888771.gif: Image format is not supported.
The file exist, but i can't show.
GIF are not supported??
this is the image url
https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v2/yo/r/UlIqmHJn-SK.gif
https://play.google.com/store/apps/developer?id=Arcadia Solutions
if only anonymous photos are gif, you can use pre converted ready jpg image
if others images also can be gif, then maybe you would need something like this:
http://ittner.github.io/lua-gd/manual.html