Dear all,
I am trying to create a function for ppl to click a button and then allow them to post a feed (or dialogue? which one is better?) on their wall.
here is my code:
local _W=display.contentWidth
local _H=display.contentHeight
local facebook = require “facebook”
local fb_username = “” – this should be the name
local fb_gender = “” – him or her
local attachement = {
name = fb_username…" has a new record!",
message = fb_username…" has a new record!",
link = “the link url”,
caption = “the caption”,
description = “The record of “…fb_username…” is “…fb_record…”, let’s try to beat “…fb_gender…” now!”,
picture = “xxx.jpg”,
}
local appId = “1234567890102010” – i know it is app id
local btn = display.newRect(0,0,100,100)
btn:setFillColor(255,255,255)
btn.x,btn.y = _W/2, _H/2
local function facebooklistener(event)
if(event.type == “session”) then
if event.phase == “login” then
facebook.request(“me/feed”,“POST”,attachement)
end
elseif(event.type == “request”) then
end
end
local function facebookfun ()
facebook.login(appId,facebooklistener,{“publish_actions”})
end
btn:addEventListener(“tap”,facebookfun)
by this, i can successfully post on facebook after login, however, i woundering when will the event.type == “request” ?
I want to change the username and gender to fit the user information…
i know you can do something like:
response = event.response
data = json.decode(response)
fb_username = data.username – i don’t know if it is right / wrong…
…etc…
in the “request” block, but it seems that the esleif (event.type==“request”) will never call
can anyone help? i will explain more if needed.