簡體   English   中英

如何從使用鈦金屬Appcelerator創建的iPhone應用程序在Facebook上共享視頻/音頻文件

[英]How to share video / audio file on facebook from iPhone app created using titanium appcelrator

我想在Facebook上共享任何類型的視頻/音頻文件。
我可以分享身份或其他所有東西,除了音頻/視頻。我在鈦工作。 這是我的代碼

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.');
            }
    });  });

您只將文件路徑( nativePath )傳遞給Facebook,而是嘗試像這樣傳遞實際的圖像blob:

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM