One of my app is to upload video to facebook account. I checked on web, but found that most of solution are old or removed. Is there any updated solution?
Welcome any comment
One of my app is to upload video to facebook account. I checked on web, but found that most of solution are old or removed. Is there any updated solution?
Welcome any comment
This website has a lot of great API references and specific one just for Facebook check it out and also check your grammar.
http://developer.coronalabs.com/reference
Context
Before you can publish onto Facebook, you must get publish (write) permissions, using either native integration or the Facebook SDK, the rule is you must first acquire read permissions before write permissions.
Thus, make sure that before you attempt to upload a video, you should have requested basic info (email for example), then, once you have this, you can request write permissions. The permission necessary for uploading videos is
publish_stream
.Using iOS 6 native Facebook integration
Using the native iOS 6 Facebook integration, you should use the
requestForServiceType:requestMethod:URL:parameters:
method ofSLRequest
, as follows:Here it's important to note that the video data does not go into the parameters dictionary, it must be added to the
SLRequest
object using theaddMultipartData:withName:type:filename:
method.Also note that the filename is very important when adding the videos data. Here I am just using the full path of the file.
Using Facebook SDK 3.1 library
If you must support iOS versions earlier then iOS 6 or you wish to use the Facebook SDK 3.1 for any other reason, uploading a video is a little different.
You must use a
FBRequest
object and aNSDictionary
that contains the videos details. The method I recommend using isrequestWithGraphPath:parameters:HTTPMethod:
, I've used this method out of preference although you should be able to use some of the other methods to create your request object.The following code works with Facebook SDK 3.1 to upload a video:
Here as you can see, we add the videos data into the
parameters
dictionary unlike the previous solution, it's there along withtitle
anddescription
(which are 2 optional parameters). Also note that here there is no keysource
, as specified by the Facebook documentation. The key's name is the filename of the video. I don't know why this shouldn't besource
, but using source results in a com.facebook.sdk error 5.The bug I mentioned I filed with Facebook, you can see this report on this link - unless I'm mistaken in my interpretation of the documentation. Please try out that bug and report if you can reproduce it. Thanks !
publish_stream
is not enough to upload(read), you need to ask for "video_upload
" permission.