Facebook - Is it possible to post a photo to a facebook page?

Is it possible?

For posting to the user’s timeline, we do this
[lua]local imageInfo = {
baseDir=system.DocumentsDirectory,
filename=slideShowFunctions.currentImage.fileName,
type=“image”
}

local attachment = {
message = “Hello! :)”,
link = “http://www.google.com”,
source = imageInfo,
}
facebook.request( “drawnguessgame/photos”, “POST”, attachment )[/lua]
and for posting on a page’s wall we do this,
[lua]facebook.request( “MyPage/feed”, “POST”, {message = shareText} )[/lua]
So I tried
[lua]facebook.request( “MyPage/photos”, “POST”, attachment )[/lua]
but that doesn’t seem to work… it still posts on my wall.

Any ideas? [import]uid: 64174 topic_id: 33480 reply_id: 333480[/import]

Satheesh,

Please see the following blog post on how to upload images to facebook…
http://www.coronalabs.com/blog/2011/12/16/uploading-photos-to-facebook-in-corona/
[import]uid: 32256 topic_id: 33480 reply_id: 133097[/import]

Our GGFacebook lib is very easy to implement and allows for uploading photos - https://github.com/GlitchGames/GGFacebook [import]uid: 119420 topic_id: 33480 reply_id: 133101[/import]

[lua]local attachment = {
message = “Random FB tests for an app”,
source = { baseDir=system.ResourceDirectory, filename=currentImage, type=“image” }
}
facebook.request( “me/photos”, “POST”, attachment )[/lua]

Pulled that out of one am working on currently, it will create an album in the name of the app then add all images you upload this way to it.

Peach :slight_smile: [import]uid: 52491 topic_id: 33480 reply_id: 133118[/import]

@Joshua,Peach and Glitch Games

I should have made myself clearer…

I want to share my image not on my timeline but in the wall of another facebook page say for instance the FB page of Corona Labs

Does that make sense?
Is that possible? [import]uid: 64174 topic_id: 33480 reply_id: 133142[/import]

Satheesh,

Please see the following blog post on how to upload images to facebook…
http://www.coronalabs.com/blog/2011/12/16/uploading-photos-to-facebook-in-corona/
[import]uid: 32256 topic_id: 33480 reply_id: 133097[/import]

Our GGFacebook lib is very easy to implement and allows for uploading photos - https://github.com/GlitchGames/GGFacebook [import]uid: 119420 topic_id: 33480 reply_id: 133101[/import]

[lua]local attachment = {
message = “Random FB tests for an app”,
source = { baseDir=system.ResourceDirectory, filename=currentImage, type=“image” }
}
facebook.request( “me/photos”, “POST”, attachment )[/lua]

Pulled that out of one am working on currently, it will create an album in the name of the app then add all images you upload this way to it.

Peach :slight_smile: [import]uid: 52491 topic_id: 33480 reply_id: 133118[/import]

@Joshua,Peach and Glitch Games

I should have made myself clearer…

I want to share my image not on my timeline but in the wall of another facebook page say for instance the FB page of Corona Labs

Does that make sense?
Is that possible? [import]uid: 64174 topic_id: 33480 reply_id: 133142[/import]

Satheesh,

I’m pretty sure facebook won’t allow you to do that because it would be a security issue. You can only post photos to a facebook account’s page/timeline that you have signed in for. For example, you can’t post a photo to Corona Lab’s facebook page because you do not know the account login. This prevents people from spamming to other people’s facebook pages. But that said, when you post to the end-user’s facebook page, that posting will be visible to that person’s friends anyways, if that’s what you are after. [import]uid: 32256 topic_id: 33480 reply_id: 133587[/import]

@Joshua
Makes sense not to allow posting on any random page…

Let me explain in detail…

I am using this Facebook Wrapper module to test Facebook posting on the Corona simulator.

I am using an account which is not an administrator of a page “myPage”(the page where I want to post)…

When I make the following call,
[lua]libFacebook.request(“myPage/feed”, “POST”, {message = “testing”}, listener)[/lua]
a post is made on my Facebook page “myPage” with the status “testing”… So far fine.
Now I want to post a photo on myPage’s wall… Since posting on the page’s wall can be done, I am assuming posting a photo would also be possible…

any ideas?
EDIT

I know some pages don’t allow users to post unless the user likes the page… But myPage’s settings allow any user to post on the page. So that’s not a problem.

I just want to know how to post photos on the page’s wall…
I tried
[lua]local imageInfo = {
baseDir=system.DocumentsDirectory,
filename=“myImage.jpg”,
type=“image”
}

local attachment = {
message = “Hello! :)”,
source = imageInfo,
}
facebook.request( “myPage/photos”, “POST”, attachment )[/lua]

but that doesn’t work… in the Facebook wrapper module,
the facebook request for the above would be
[lua]libFacebook.request(“myPage/photos”, “POST”, {message = “testing”}, listener)[/lua]
but I do not know how to manually send the image data in the POST request… Some sources said you have to send image as Multipart form data but I have no idea how to do that(I tried using this method but that didn’t work).

Any help is appreciated!
Thanks! [import]uid: 64174 topic_id: 33480 reply_id: 133617[/import]

The multi-part form upload you referenced does work, I’d guess dozens of people are successfully using it… But not for facebook uploading… To upload an image to facebook, you need to have the image (jpg or png) saved on the device, and make a reference to it… My code to upload a photo to facebook is the same as Peach’s:

[code]
local attachment = {
message = currMess.MESSAGE,
source = {
baseDir=system.TemporaryDirectory,
filename=fileLocation,
type=“image”
},
}

facebook.request( “me/photos”, “POST”, attachment )
[/code] [import]uid: 79933 topic_id: 33480 reply_id: 133629[/import]

@mpappas

As I mentioned before, I want to share my image not on my timeline but in the wall of another facebook page [import]uid: 64174 topic_id: 33480 reply_id: 133630[/import]

@satheesh – OK, got ya finally… I think because of your initial post, and use of MyPage (as opposed to otherPage or something), I kept thinking it was your page, not someone elses… Anyways… I think I saw something recently about facebook deprecating posting to others walls because of spam…

Yep, here it is: http://blog.programmableweb.com/2012/10/11/facebook-api-dropping-post-to-wall-immediately/

Not sure if it’s totally kaput now, or what they recommend… But that might 'splain it. [import]uid: 79933 topic_id: 33480 reply_id: 133632[/import]

Satheesh,

I’m pretty sure facebook won’t allow you to do that because it would be a security issue. You can only post photos to a facebook account’s page/timeline that you have signed in for. For example, you can’t post a photo to Corona Lab’s facebook page because you do not know the account login. This prevents people from spamming to other people’s facebook pages. But that said, when you post to the end-user’s facebook page, that posting will be visible to that person’s friends anyways, if that’s what you are after. [import]uid: 32256 topic_id: 33480 reply_id: 133587[/import]

@Joshua
Makes sense not to allow posting on any random page…

Let me explain in detail…

I am using this Facebook Wrapper module to test Facebook posting on the Corona simulator.

I am using an account which is not an administrator of a page “myPage”(the page where I want to post)…

When I make the following call,
[lua]libFacebook.request(“myPage/feed”, “POST”, {message = “testing”}, listener)[/lua]
a post is made on my Facebook page “myPage” with the status “testing”… So far fine.
Now I want to post a photo on myPage’s wall… Since posting on the page’s wall can be done, I am assuming posting a photo would also be possible…

any ideas?
EDIT

I know some pages don’t allow users to post unless the user likes the page… But myPage’s settings allow any user to post on the page. So that’s not a problem.

I just want to know how to post photos on the page’s wall…
I tried
[lua]local imageInfo = {
baseDir=system.DocumentsDirectory,
filename=“myImage.jpg”,
type=“image”
}

local attachment = {
message = “Hello! :)”,
source = imageInfo,
}
facebook.request( “myPage/photos”, “POST”, attachment )[/lua]

but that doesn’t work… in the Facebook wrapper module,
the facebook request for the above would be
[lua]libFacebook.request(“myPage/photos”, “POST”, {message = “testing”}, listener)[/lua]
but I do not know how to manually send the image data in the POST request… Some sources said you have to send image as Multipart form data but I have no idea how to do that(I tried using this method but that didn’t work).

Any help is appreciated!
Thanks! [import]uid: 64174 topic_id: 33480 reply_id: 133617[/import]

The multi-part form upload you referenced does work, I’d guess dozens of people are successfully using it… But not for facebook uploading… To upload an image to facebook, you need to have the image (jpg or png) saved on the device, and make a reference to it… My code to upload a photo to facebook is the same as Peach’s:

[code]
local attachment = {
message = currMess.MESSAGE,
source = {
baseDir=system.TemporaryDirectory,
filename=fileLocation,
type=“image”
},
}

facebook.request( “me/photos”, “POST”, attachment )
[/code] [import]uid: 79933 topic_id: 33480 reply_id: 133629[/import]

@mpappas

As I mentioned before, I want to share my image not on my timeline but in the wall of another facebook page [import]uid: 64174 topic_id: 33480 reply_id: 133630[/import]

@satheesh – OK, got ya finally… I think because of your initial post, and use of MyPage (as opposed to otherPage or something), I kept thinking it was your page, not someone elses… Anyways… I think I saw something recently about facebook deprecating posting to others walls because of spam…

Yep, here it is: http://blog.programmableweb.com/2012/10/11/facebook-api-dropping-post-to-wall-immediately/

Not sure if it’s totally kaput now, or what they recommend… But that might 'splain it. [import]uid: 79933 topic_id: 33480 reply_id: 133632[/import]