Share Screenshot on Facebook

Does anyone know how to share a screenshot on Facebook? I used this code before Graphics 2.0 and it worked just fine, but not what I’m using post 2.0, it seemed to stop working. Assuming I’ve set up my build.settings file up correctly with the FB ids, is there something wrong with my code below?

local function onLoginSuccess()                 local screenshotDirectory = system.DocumentsDirectory                 local screenshot = "ss\_"..os.date("%Y%m%d%H%M%S") .. ".jpg"                 display.save(group, screenshot, screenshotDirectory)                 local attachment = {                     message = "I need help! Do you know the name of this puzzle in "..\_APPNAME.."? "..\_HASHTAG,                     --source = { baseDir=system.ResourceDirectory, filename="background.jpg", type="image" }                     source = { baseDir=screenshotDirectory, filename=screenshot, type="image" }                 }                 facebook.request( "me/photos", "POST", attachment )             end             -- login to facebook and post something             local function fbListener( event )                 if event.isError then                     native.showAlert( "Facebook ERROR", event.response, { "OK" } )                 else                     if event.type == "session" and event.phase == "login" then                         -- login was a success; call function                         onLoginSuccess()                         --native.showAlert( "2", "2", { "OK" } )                     elseif event.type == "request" then                         -- this block is executed upon successful facebook.request() call                         native.showAlert( "Facebook Post Successful!", "This puzzle has been uploaded to Facebook. Your friends should help you soon!", { "OK" } )                     end                 end             end             local fbAppID = \_FACEBOOKID --not fake             facebook.login( fbAppID, fbListener, { "publish\_stream" } )  

I figured out the issue. Instead of using group, I should be using scene.view. For anyone else that stumbles across this, the code above will post a screenshot to Facebook assuming you have everything else set up (i.e. build.settings file).

I figured out the issue. Instead of using group, I should be using scene.view. For anyone else that stumbles across this, the code above will post a screenshot to Facebook assuming you have everything else set up (i.e. build.settings file).

Hi Daniel,

please, could you share your build.settings file?

I am experiencing problems on Android.

Thanks!

With the latest Corona build, you’ll have to require the Facebook plugin. I’m on my phone right now, but it’s something like

settings = {

plugins =
{
[“facebook”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, [“iphone-sim”]=true },
},
},
}

thanks!

Hi Daniel,

please, could you share your build.settings file?

I am experiencing problems on Android.

Thanks!

With the latest Corona build, you’ll have to require the Facebook plugin. I’m on my phone right now, but it’s something like

settings = {

plugins =
{
[“facebook”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, [“iphone-sim”]=true },
},
},
}

thanks!