Posting a screenshot to Facebook

Hi there !

I’ve been trying to publish a screenshot made on my app to my Facebook feed with the Facebook plugin.

Just to be clear, I’m not talking about this kind of post :

fb_post.png

… but I’m talking about this kind of post :

test.png

I felt I had to specify because I’m using the Facebook sample as a template, and the Post Photo button does post a picture, but only the first type.

So, in order to post my picture, I’m using this :

The Facebook login is made with that line :

facebook.login(fbAppID, facebookListener)

Then I add a listener to a button calling this function

facebook.login(fbAppID, facebookListener, {"publish\_actions"})

And I try to upload a picture from the Resource Directory (note that I’m not trying to upload a custom screenshot yet) :

function uploadPictureToFacebook() local attachment = { message="I took a picture !", source= {baseDir=system.ResourceDirectory, filename="images/facebook.png", type="image"} } -- posting the photo facebook.request( "me/photos", "POST", attachment ) end 

And… nothing. Everything else works (posting a status, a link, etc…). but this one doesn’t.

Is this actually possible with the Facebook Plugin, because I can’t find much on the forum on this topic ?

Thank you in advance ! 

Am I the only one who can’t see the pics?

If you can’t the pics, you can see them here :

First kind of post (that I don’t want to do).

Second kind of post (That I want to do)

Almost solved !

Ok… So, I’ve made a looooot of tests. What seems to break all of this is the message parameter. I’ve managed to post *once* with this code (and I don’t understand why…) :

function uploadPictureToFacebook() local attachment = { message="", source= {baseDir=system.ResourceDirectory, filename="images/facebook.png", type="image"} } -- posting the photo facebook.request( "me/photos", "POST", attachment ) end 

I removed the pre-filled text in the message parameter. Like I said, it worked only once and never worked again.

Then, I tried it by removing completely the message parameter !

function uploadPictureToFacebook() local attachment = { source= {baseDir=system.ResourceDirectory, filename="images/facebook.png", type="image"} } -- posting the photo facebook.request( "me/photos", "POST", attachment ) end 

And, it seems to work for now.

But, now, I encounter an other problem : if the user removes the photo album containing all the pictures, he won’t be able to post, never again. Except if he :

  • Uninstalls the Facebook App and all of its autorisations.

  • Removes the app from his mobile and reinstalls it.

Is there any way to avoid that ?

Can’t wait to test it on android :slight_smile:

I’m not sure what platforms you’re talking about, but you may be interested in this discussion about FB sharing:

http://forums.coronalabs.com/topic/52755-can-corona-enable-limited-facebook-sharing-on-android-via-nativeshowpopup/

Do you know if there’s some kind of delay with Facebook ?

Right now, I’m pretty sure my code works. Yesterday, I’ve been able to post pictures without any problems. Then, in order to understand what was happening, I did that :

  • I deleted the app from my iPhone

  • I removed the photo album and all the photos from my Facebook profile.

  • I removed the Facebook App from my profile

And then…

  • Reinstalled the app on my iPhone

  • Logged to Facebook within my app

  • Successfully logged and installed the app on my Facebook profile

  • Tried to upload a photo from the app to my Facebook profile

It failed. I was able to post anything (status, score, etc) but no “simple post” with only a picture. I couldn’t understand why and what was happening.

A few hours later, without changing anything, I relaunched my app, and tried to share a picture again. And it worked.

… So, could it be a problem of delay ? Is it because I deleted the photo album and the facebook app from my profile and then tried too soon to publish my picture ?

I’d really appreciate your help, I’m kinda losin’ it …

Am I the only one who can’t see the pics?

If you can’t the pics, you can see them here :

First kind of post (that I don’t want to do).

Second kind of post (That I want to do)

Almost solved !

Ok… So, I’ve made a looooot of tests. What seems to break all of this is the message parameter. I’ve managed to post *once* with this code (and I don’t understand why…) :

function uploadPictureToFacebook() local attachment = { message="", source= {baseDir=system.ResourceDirectory, filename="images/facebook.png", type="image"} } -- posting the photo facebook.request( "me/photos", "POST", attachment ) end 

I removed the pre-filled text in the message parameter. Like I said, it worked only once and never worked again.

Then, I tried it by removing completely the message parameter !

function uploadPictureToFacebook() local attachment = { source= {baseDir=system.ResourceDirectory, filename="images/facebook.png", type="image"} } -- posting the photo facebook.request( "me/photos", "POST", attachment ) end 

And, it seems to work for now.

But, now, I encounter an other problem : if the user removes the photo album containing all the pictures, he won’t be able to post, never again. Except if he :

  • Uninstalls the Facebook App and all of its autorisations.

  • Removes the app from his mobile and reinstalls it.

Is there any way to avoid that ?

Can’t wait to test it on android :slight_smile:

I’m not sure what platforms you’re talking about, but you may be interested in this discussion about FB sharing:

http://forums.coronalabs.com/topic/52755-can-corona-enable-limited-facebook-sharing-on-android-via-nativeshowpopup/

Do you know if there’s some kind of delay with Facebook ?

Right now, I’m pretty sure my code works. Yesterday, I’ve been able to post pictures without any problems. Then, in order to understand what was happening, I did that :

  • I deleted the app from my iPhone

  • I removed the photo album and all the photos from my Facebook profile.

  • I removed the Facebook App from my profile

And then…

  • Reinstalled the app on my iPhone

  • Logged to Facebook within my app

  • Successfully logged and installed the app on my Facebook profile

  • Tried to upload a photo from the app to my Facebook profile

It failed. I was able to post anything (status, score, etc) but no “simple post” with only a picture. I couldn’t understand why and what was happening.

A few hours later, without changing anything, I relaunched my app, and tried to share a picture again. And it worked.

… So, could it be a problem of delay ? Is it because I deleted the photo album and the facebook app from my profile and then tried too soon to publish my picture ?

I’d really appreciate your help, I’m kinda losin’ it …