Sharing local image file to facebook

Hi there, 

 

I am trying to implant the function for sharing the photos to facebook, using the Corona Demo for facebook.

the code is :

local photoData = {                                 photos = {                                     { url = "https://coronalabs.com/wp-content/uploads/2014/11/Corona-Icon.png", },                                     { url = "https://www.coronalabs.com/links/demo/Corona90x90.png", },                                             },                                 }             facebook.showDialog( "photo",photoData)

and it is post successfully.

 

My question is : 

Is it possible to share the photo in the local path such as “system.DocumentsDirectory”?

and how is the param for the table?

 

thanks

 

Vincent

Facebook want an image at a URL to get. Clearly uploading an image to a file service, getting the URL to it and providing that to the Facebook API call may be the simplest way to do this. They document that you can use a URL or you can upload file. The problem is there are no good examples of using the file method.

I don’t know if the showDialog method will work with this, but the facebook.request() API using the /photos endpoint should work.

According to: http://stackoverflow.com/questions/4999024/facebook-graph-api-upload-photo-using-javascript

You can create multi-part form data with the properly encoded binary image and send it. There is a Corona based Multi-part library at: 

https://github.com/breinhart/Corona-SDK-Tweet-Media/blob/master/utils/multipartForm.lua

That was used to send photos to twitter in the early days. You probably could adapt this to create the multipart form data and then use the stackoverflow post to figure out how to upload it via the Graph API /photos end point.

Rob

Hi Rob,

thanks, I am a rookie for Corona, so i am not quite understand your solution, but I’ll try to figure out the way.

And by the way, Is the free version of Corona support Facebook API call?

Best

Vincent

Yes, facebook is available to the free version.

Rob

Facebook want an image at a URL to get. Clearly uploading an image to a file service, getting the URL to it and providing that to the Facebook API call may be the simplest way to do this. They document that you can use a URL or you can upload file. The problem is there are no good examples of using the file method.

I don’t know if the showDialog method will work with this, but the facebook.request() API using the /photos endpoint should work.

According to: http://stackoverflow.com/questions/4999024/facebook-graph-api-upload-photo-using-javascript

You can create multi-part form data with the properly encoded binary image and send it. There is a Corona based Multi-part library at: 

https://github.com/breinhart/Corona-SDK-Tweet-Media/blob/master/utils/multipartForm.lua

That was used to send photos to twitter in the early days. You probably could adapt this to create the multipart form data and then use the stackoverflow post to figure out how to upload it via the Graph API /photos end point.

Rob

Hi Rob,

thanks, I am a rookie for Corona, so i am not quite understand your solution, but I’ll try to figure out the way.

And by the way, Is the free version of Corona support Facebook API call?

Best

Vincent

Yes, facebook is available to the free version.

Rob