Hi Guys,
I have a code that can post/share some info to our FB wall.
But when I build with newest Corona, that’s not work.
This code is show a alert before and after post at our FB wall
I use this code :
local buttonFacebookKlik = function( event )
if event.phase == “release” and buttonFacebook.isActive then
audio.play( tapSound )
– director:changeScene( “menu__” )
local facebook = require “facebook”
local fbAppID = “xxxxxxxxxxxxxxxxxxx”
local data
local callAlert2 = function()
local onComplete2 = function(event)
if “clicked” == event.action then
local i = event.index
if i == 1 then
– do nothing just close alert
elseif i == 2 then
– update
– facebook.login( fbAppID, facebookListener2, { “publish_stream” } )
end
facebook.logout( )
end
end
– local alert = native.showAlert(“Info”,“User “…data.name…” Share”,
local alert = native.showAlert(“Info”,“User”,
{“Next”},onComplete2)
end
local facebookListener2 = function(event)
if (“session”==event.type ) then
if(“login” == event.phase) then
local namapedjuang
if name[1]==“name1” then
namapedjuang = “name1”
elseif name[1]==“name2” then
namapedjuang = “name2”
elseif name[1]==“name3” then
namapedjuang = “name3”
elseif name[1]==“name4” then
namapedjuang = “name4”
end
local statusUpdate = “User “…name…” reward “…point[1]…” point!”
facebook.request(“me/feed”,“POST”,{
message = statusUpdate,
name = “Testing Title”,
caption = “Testing Body”,
link = “http://some_url.com”,
picture = “http://some_url.com/image/1.png”})
theTimers.newTimer = timer.performWithDelay( 1000, callAlert2, 1 )
elseif (“request”==event.type) then
if not event.isError then
end
end
end
end
local callAlert1 = function()
local onComplete = function(event)
if “clicked” == event.action then
local i = event.index
if i == 2 then
– do nothing just close alert
elseif i == 1 then
– update
facebook.login( fbAppID, facebookListener2, { “publish_stream” } )
end
end
end
– local alert = native.showAlert("For “…data.name…” ",“Are You Sure?”,
local alert = native.showAlert("For ",“Are You Sure?”,
{“Yes”,“No”},onComplete)
end
local facebookListener = function(event)
if (“session” == event.type ) then
if (“login” == event.phase) then
– local updateStatus = “”
callAlert1()
--facebook.request(“me”)
end
elseif (“request”==event.type) then
– event.response is a JSON object from the FB server
--local response = event.response
– if request succeeds, create a scrolling list of friend names
--[[if ( not event.isError ) then
response = json.decode( event.response )
data = response.data
callAlert1()
end
--]]
end
end
facebook.login( fbAppID, facebookListener, { “publish_stream” } )
end
end
buttonFacebook = ui.newButton{
id=“buttonFacebook”, defaultSrc=“image/button/buttonfacebook.png”,
defaultX = 35, defaultY = 35,
overSrc = “image/button/buttonfacebook.png”,
overX = 40,
overY = 40,
emboss = false, text = “”,
onEvent=buttonFacebookKlik
}
buttonFacebook.x = 240 ; buttonFacebook.y = 280
localGroup:insert( buttonFacebook )
if tonumber(point[1])== 0 then
buttonFacebook.isActive=false
buttonFacebook.isVisible=false
end
end
Now, thats code can work properly
Please some advise.
Regards,
Abdul Aziz