I want to share video / audio any kind of file on Facebook .
I am able share status or other all stuffs except audio / video.i am working in titanium . here is my code
login.addEventListener('click', function(e){
Titanium.Facebook.authorize();
var f=Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory+"/"+"audio"+"/"+"abc.mp4");
var blob=f.nativePath;
alert(blob);
var data={
message: 'Check this video!',
video: blob
}
Titanium.Facebook.requestWithGraphPath('me/videos', data, 'POST', function(e) {
if (e.success)
{
alert("Success! From FB: " + e.result);
} else if (e.error) {
alert(e.error);
} else {
alert('Unknown response.');
}
}); });
You are only passing the file path ( nativePath
) to Facebook, instead try passing the actual image blob like this:
var blob=f.read();
var data={
message: 'Check this video!',
video: blob
}
// The rest....
var url = "https://graph-video.facebook.com/me/videos";
Titanium.Facebook.authorize();
var xhr_video = Titanium.Network.createHTTPClient();
xhr_video.open('POST', url);
xhr_video.setRequestHeader('Content-Type', 'multipart/form-data');
xhr_video.onload = function(e) {
alert("Video Has Been Successfully Posted to Your Timeline");
};
xhr_video.onerror = function(e) {
alert(e);
xhr_video.abort();
};
var f=Titanium.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory+"/"+"audio"+"/"+"video.mp4");
var blob=f.read();
var data = {
video : blob,
//access_token : Titanium.Facebook.getAccessToken()
access_token:Ti.Facebook.accessToken
};
alert(data);
xhr_video.send(data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.