Posting photo on facebook

I followed this guide http://coronalabs.com/blog/2011/12/16/uploading-photos-to-facebook-in-corona/ to upload photo from my project folder to facebook. But it doesn’t seem to work. Does anyone know how to post pictures from your project folder on facebook.

This is what I used and its not working.

if ( “login” == event.phase ) then
            local access_token = event.token
            --code for tasks following a successful login
             local attachment = {
                name = “I got stuck with this”,
                message = “Just a description of the photo.”,
                --link = “http://www.coronalabs.com/links/forum”,
                source = { baseDir=system.ResourceDirectory, filename=“Capture1.jpg”, type=“image” },
                --caption = “Shadow Quiz”,
                --description = “Corona SDK for developing iOS and Android apps with the same code base.”,
                --picture = “http://www.coronalabs.com/links/demo/Corona90x90.png”,
                actions = print(“attachment”)
            }
            print(“post command is coming”)
            facebook.request( “me/feed”, “POST”,attachment )
        end
 

If I comment the source variable and uncomment the other variables then the “picture” gets posted. But I don’t want to post from an image url. I want to post an image from my project folder.

Hi @anirbond,

Facebook can be fickle and that blog post is very old. Perhaps you’ll benefit from a more current discussion like this one:

http://forums.coronalabs.com/topic/44834-posting-images-within-a-message-post-or-tweet-to-facebook-and-twitter-on-android/

Take care,

Brent

I checked that blog. The actual code that is used to post the photo on facebook doesn’t seem to have changed in the link above.

I have been trying and trying for 2 days now to post a photo from device on facebook. Please help! Is there no one who has successfully done it many times of late??

Hi @anirbond,

Can you post more details about what is not working? Error messages and such? Did you do some basic debugging? The community may be able to help you further if you provide specific details.

Brent

Is the problem only happening with a image from your ResourceDirectory? Is this happening only on Android?

Well I switched to posting the photo in my photo album instead of my wall. That is instead of using facebook.request( “me/feed”, “POST”,attachment ) I’m now using facebook.request( “me/photos”, “POST”,attachment ).

That works. So is it not possible to post a picture on the wall and not in any album? I wanted to post a photo on the wall along with a message and caption and description and a link to my app. Just like it’s done in the sample code for facebook in corona. Except that instead of a url image I wanted to use an image from device.

So when I replace the ‘picture’ variable with the ‘source’ variable, for posting in ‘me/feed’, it doesn’t work.

I believe there is no way to upload an image directly to the feed. You need to upload the image to Facebook, get the image id from the Facebook response, and post to the feed using the image id. Note that there appears to be a bug in the current public version of Corona that prevents image uploads (see http://forums.coronalabs.com/topic/45743-facebook-share-photo-via-mephotos-request-has-broken/#entry239669).

Hi @anirbond,

Facebook can be fickle and that blog post is very old. Perhaps you’ll benefit from a more current discussion like this one:

http://forums.coronalabs.com/topic/44834-posting-images-within-a-message-post-or-tweet-to-facebook-and-twitter-on-android/

Take care,

Brent

I checked that blog. The actual code that is used to post the photo on facebook doesn’t seem to have changed in the link above.

I have been trying and trying for 2 days now to post a photo from device on facebook. Please help! Is there no one who has successfully done it many times of late??

Hi @anirbond,

Can you post more details about what is not working? Error messages and such? Did you do some basic debugging? The community may be able to help you further if you provide specific details.

Brent

Is the problem only happening with a image from your ResourceDirectory? Is this happening only on Android?

Well I switched to posting the photo in my photo album instead of my wall. That is instead of using facebook.request( “me/feed”, “POST”,attachment ) I’m now using facebook.request( “me/photos”, “POST”,attachment ).

That works. So is it not possible to post a picture on the wall and not in any album? I wanted to post a photo on the wall along with a message and caption and description and a link to my app. Just like it’s done in the sample code for facebook in corona. Except that instead of a url image I wanted to use an image from device.

So when I replace the ‘picture’ variable with the ‘source’ variable, for posting in ‘me/feed’, it doesn’t work.

I believe there is no way to upload an image directly to the feed. You need to upload the image to Facebook, get the image id from the Facebook response, and post to the feed using the image id. Note that there appears to be a bug in the current public version of Corona that prevents image uploads (see http://forums.coronalabs.com/topic/45743-facebook-share-photo-via-mephotos-request-has-broken/#entry239669).