Can we upload videos from an Android device's SD Card to a Facebook account via the Facebook SDK?
If so, what are some simple examples?
Can we upload videos from an Android device's SD Card to a Facebook account via the Facebook SDK?
If so, what are some simple examples?
Yes, it is possible! After two days of trying and researching, I was able to do it. Here's the code:
where
fbRequestListener()
is an implementation ofAsyncFacebookRunner.RequestListener()
andreadBytes()
is a function of converting your video file tobyte[]
. ThedataName
string should include a valid file extension (3gp, mp4, etc.). The code is as follows:I got this function from this answer.
Of course, you need to have the latest Facebook SDK, but we need to apply this patch to fix the
{"error":{"type":"OAuthException","message":"(#352) Video file format is not supported"}}
string response error.And that's it! I hope this helps!
After patching Util file, did not get result.
I faced problem mentioned by softy.
I tried with this in android... Now works successfully.. video displayed on my wall after sometime (within 1 min).. (May be, facebook was refreshing data..)
FBRequestListener.java
With the release of new facebook SDK 3.5, video uploading has been made easier. If you are using sdk 3.5 or above here is the code for uploading video to facebook
In release of new facebook SDK, there are some changes in video uploading to facebook page or wall.
Here is code i have used for uploading video on Facebook page or facebook wall.
Your
onActivityResult()
method should be like thisHere is all method used in
onActivityResult().
Here is
GetFilePathFromDevice
class used inonActivityResult()
for getting file path from URI.