Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
callback in facebook calls — Gideros Forum

callback in facebook calls

arcadiaarcadia Member
edited October 2013 in General questions
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)

Likes: ricvieira

+1 -1 (+1 / -0 )Share on Facebook

Comments

Sign In or Register to comment.