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

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

[lua]facebook.request(“me/photos”, “POST”, {message=“My Photo”, source=theRelevantEncoder(myImageOrFile)[/lua]

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 [import]uid: 6645 topic_id: 8179 reply_id: 308179[/import]

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
[import]uid: 6645 topic_id: 8179 reply_id: 29264[/import]

+1

Sounds like something alot of us could use. [import]uid: 8872 topic_id: 8179 reply_id: 29647[/import]

+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. [import]uid: 27636 topic_id: 8179 reply_id: 29675[/import]

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)

[lua]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)[/lua]

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)
[import]uid: 6645 topic_id: 8179 reply_id: 29677[/import]

+1
essential [import]uid: 4413 topic_id: 8179 reply_id: 30608[/import]

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 [import]uid: 24 topic_id: 8179 reply_id: 30648[/import]

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. [import]uid: 6645 topic_id: 8179 reply_id: 30659[/import]

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. [import]uid: 52430 topic_id: 8179 reply_id: 74245[/import]