I'm using Titanium SDK 3.1.1 and deploying for both iOS and Android. I tried the answer in this post, I modified it to use it with the new Facebook Module authorizing methods like this:
var fb = require('facebook'); fb.appid = 186607908179444; fb.permissions = ['publish_stream']; // Permissions your app needs fb.forceDialogAuth = false;The code I use to make the request was this:
var url = "https://graph-video.facebook.com/me/videos"; 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 tmp = Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory, ('baby_temp.mp4')); var data = { video : tmp.read(), access_token : fb.accessToken }; xhr_video.send(data);but I got a Connection to https://graph-video.facebook.com refused. I also tried to use the Facebook Module's requestWithGraphPath method like this:
fb.requestWithGraphPath('me/videos', args, "POST", function(e) { if (e.success) { Ti.API.info('media post is successful'); } else { Ti.API.info('something went off while sharing media'); activatedFacebookSharing = false; if (e.error) { alert(e.error); } else { alert("Unkown result"); } } });But this returned me a Sorry, the video file you selected is in a format that we don't support error.
What's the proper way to upload a video to Facebook using Titanium SDK 3.1 and later?