Still can’t seem to get photo posting to work, even when I use a concrete URL as the “source” - I am beginning to wonder if this is a bug in Corona’s Facebook API.
Regardless, I am more interested at the moment in figuring out how to transplant a variable into the “picture” parameter in the code below. Everything I’ve tried does not work. The problem seems to be that the facebook.request won’t work unless the entire picture parameter falls within quotation marks, but if I place the variable within the quotation marks, it doesn’t register as a variable, but rather as part of the string. Also, I tried removing the ( ) as you suggested, with no luck.
If I skip the variable issue and define a specific URL for my FTP upload, and then point the “picture” parameter to that URL, things are working just fine - so the file definitely finishes uploading before the URL posts to FB. And my variable naming scheme is also working: I can upload using the variable with expected results (but I can’t direct FB to the variable-named URL).
Below is the piece of my code related to this issue. Please take a look if you can and let me know if you have any thoughts. Apologies for any messy or inefficient code (I’m still pretty new at this). Thanks again for your help on this issue.
(FYI, I substituted a string of X’s for my actual Facebook App ID - it seemed strange to post that on a public forum. And my “button” is just a plain rectangle for the moment - I want to get it’s functionality working before I “nice it up.”)
Thanks,
Jason
[code]
– listener for “fbconnect” events
local function listener( event )
if ( “session” == event.type ) then
if ( “login” == event.phase ) then
facebook.request( “me/feed”, “POST”, {
picture = (“http://www.jasonschroeder.com/pins/” … imagename),
message = “Check out this composition I made using ‘Pins!’”
} )
end
elseif ( “request” == event.type ) then
– event.response is a JSON object from the FB server
local response = event.response
print( response )
end
imagename:removeSelf()
imagename=nil
end
local function fbupload()
– first argument is the app id that you get from Facebook
facebook.login( “XXXXXX”, listener, {“publish_stream”} )
end
local function ftpupload()
local imagename = (system.getInfo( “deviceID” ) … system.getTimer()) … “.jpg”
connection:upload{
localFile = system.pathForFile(“screencapture.jpg”, system.TemporaryDirectory),
remoteFile = imagename
}
fbupload()
end
local function screengrab ()
display.save( localGroup, “screencapture.jpg”, system.TemporaryDirectory)
ftpupload()
end
local fbbutton = display.newRect(display.contentWidth*.2,display.contentHeight*.9,60,60)
fbbutton:addEventListener(“tap”, screengrab)
[/code] [import]uid: 27636 topic_id: 7240 reply_id: 25865[/import]