[SOLVED] binary (mime) attachment to facebook.request

8 replies [Last post]
jmp909
User offline. Last seen 1 year 13 weeks ago. Offline
Joined: 14 May 2010

just combining posts from the links below. need to be able to upload a photo/video to facebook using the "source" (or possibly "image") attribute eg

facebook.request("me/photos", "POST", {message="My Photo", source=theRelevantEncoder(myImageOrFile)

happy to pass MIME data if we know the format up front. or a binary file read or whatever, i'm just not sure the parameter is implemented in the facebook module.

http://developer.anscamobile.com/forum/2011/02/28/displaysave-facebook-connect-can-we-post-screen-captures-fb

http://developer.anscamobile.com/forum/2011/01/28/facebook-graph-api-upload-photo-anyone-done-re-my-webinar-question

thanks
j

Replies

jmp909
User offline. Last seen 1 year 13 weeks ago. Offline
Joined: 14 May 2010

just to clarify, we would want to be able to create raw data from either a display object/group (eg from a screen capture), or a file and then pass this to the graph api "source" parameter of the "me/photos" request. corona would presumably need to detect the filetype from the extension to add the relevant content type

since presumably io.open & read can be used for getting the data of an image file, and a display group can be saved and loaded from a temporary screencapture, getting the raw image data isnt specifically an issue. it's just getting the data and it's content type into the facebook request

this would theoretically work for video uploads too

thanks
j

kam187
User offline. Last seen 11 weeks 1 day ago. Offline
Joined: 10 Sep 2010

+1

Sounds like something alot of us could use.

schroederapps
User offline. Last seen 1 day 11 hours ago. Offline
Joined: 25 Jan 2011

+1 this would be quite useful - right now we only seem to be able to post standard wall posts, but being able to actually add a photo to the user's FB photo library would be a great tool.

jmp909
User offline. Last seen 1 year 13 weeks ago. Offline
Joined: 14 May 2010

i have put a suggested functionality up on the subscribers feature/bug forum.. but for your info

this is one way I would hope it might work (it doesn't currently)

1
2
3
4
5
6
7
8
9
10
local path = system.pathForFile( "image.jpg" )
local imgfile = io.open( path, "rb" )
local imgData = ltn12.source.file(imgfile)
 
local args= {
                message="hello",
                source = imgData
}
 
facebook.request("me/photos", "POST", args)

it would also be useful to have a binary encoder for a display group (without saving to file) but I think saving to a temporary directory and reloading is a sufficient workaround

I'm not sure if Facebook required a specific content-type header (eg image/jpeg, image/png etc so this is also something that would need to be implemented if so)

bottleboy
User offline. Last seen 3 years 2 weeks ago. Offline
Joined: 7 Jan 2010

+1
essential

carlos m. icaza
User offline. Last seen 2 years 23 weeks ago. Offline
Alumni
Joined: 22 Jun 2009

You all know the drill. Enter a bug report, label it as feature, then it will go into the review pile..and put into the features list.

C

jmp909
User offline. Last seen 1 year 13 weeks ago. Offline
Joined: 14 May 2010

hi. it's already in the subscriber critical bugs forum
http://developer.anscamobile.com/forum/2011/03/24/cant-post-source-data-facebook-request-mephotos

but thanks.

jonathanbeebe
User offline. Last seen 1 year 51 weeks ago. Offline
Alumni
Joined: 12 Apr 2011

This functionality has been added as of Daily Build 2011.707.

Here's a tutorial on how to do it:
http://blog.anscamobile.com/2011/12/uploading-photos-to-facebook-in-corona/

NOTE: The tutorial includes important information regarding build.settings for any iOS app using the Facebook API in build 2011.707 and later, regardless if you intend to upload photos or not.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.