So I took the code from the example project and more or less pasted into a project I’m working on. I changed a few things around and now the statusMessage doesn’t update and the native activity indicator that displays during the network connection has moved from the center of the web view window to the 0,0 coordinates at the top left. The code does post to Facebook but the notification window isn’t updating.
If anyone can think of obvious problems that might cause this, any help would be appreciated.
[lua]-- FB Code
local function printTable( t, label, level )
if label then print( label ) end
level = level or 1
if t then
for k,v in pairs( t ) do
local prefix = “”
for i=1,level do
prefix = prefix … “\t”
end
print( prefix … “[” … tostring(k) … "] = " … tostring(v) )
if type( v ) == “table” then
print( prefix … “{” )
printTable( v, nil, level + 1 )
print( prefix … “}” )
end
end
end
end
local function createStatusMessage( message, x, y )
– Show text, using default bold font of device (Helvetica on iPhone)
local textObject = display.newText( message, 0, 0, native.systemFontBold, 14 )
textObject:setTextColor( 255,255,255 )
– A trick to get text to be centered
local group = display.newGroup()
group.x = x
group.y = y
group:insert( textObject, true )
– Insert rounded rect behind textObject
local r = 10
local roundedRect = display.newRoundedRect( 0, 0, textObject.stageWidth + 2*r, textObject.stageHeight + 2*r, r )
roundedRect:setFillColor( 55, 55, 55, 190 )
group:insert( 1, roundedRect, true )
group.textObject = textObject
return group
end
–local statusMessage = createStatusMessage( “Not connected”, 0.5*display.contentWidth, 0.70*display.contentHeight )
– moved this lower and set invisible to bring up only during social screen
local function connectHandler( event )
local post = “hello and goodbye!”
local session = event.sender
if ( session:isLoggedIn() ) then
print( "fbStatus " … session.sessionKey )
local attachment = {
name=“Developing a Facebook Connect app using the Corona SDK!”,
href=“http://developer.anscamobile.com”,
media= { { type=“image”, src=“http://developer.anscamobile.com/demo/Corona90x90.png”, href=“http://www.anscamobile.com” } }
}
local action_links = {
{ text=“Learn more”, href=“http://developer.anscamobile.com” }
}
local response = session:call{
method =“stream.publish”,
attachment = json.encode(attachment),
action_links = json.encode(action_links),
}
if “table” == type(response ) then
statusMessage.textObject.text = “Post failed”
– print contents of response upon failure
printTable( response, “fbStatus response:”, 5 )
else
statusMessage.textObject.text = “Post published”
end
end
end
–Fbook
local statusMessage = createStatusMessage( “Not connected”, 0.5*display.contentWidth, 0.70*display.contentHeight )
statusMessage.isVisible = false
local fbButtonPress = function (event)
if ( fb_api_key and fb_secret ) then
– Create Facebook connection object
local session = facebook.newConnection( fb_api_key, fb_secret )
session:login( connectHandler )
else
local function onComplete( event )
system.openURL( “http://developers.facebook.com/get_started.php” )
end
native.showAlert( “Error”, “To develop for Facebook Connect, you need to get an API key and application secret. This is available from Facebook’s website.”, { “Learn More” }, onComplete )
end
return true
–added ‘return true’ which wasn’t in the project code
end
local fbButton = ui.newButton{
default = “fbButton.png”,
over = “fbButtonOver.png”,
onRelease = fbButtonPress,
id = “fbButton”,
x = screenW/2,
y = screenH/2 - 50,
isVisible = false
}
– end FB code[/lua] [import]uid: 1560 topic_id: 2238 reply_id: 302238[/import]