2011-10-03 65 views
1

我需要能夠在Facebook上將音頻文件共享到我的牆上和朋友的牆上。另外,當我點擊用戶個人資料上的共享項目圖像時,我也必須播放音頻。我怎樣才能在Facebook個人資料中共享和播放音頻MP3文件/

我已經嘗試使用下面的函數來分享,但我不知道我怎樣才能改變形象..

function fb_share() { 
    var linkVideo = "http://www.youtube.com/watch?v=nXefLc5VXsGY"; 
    u=linkVideo; 
    t=document.title; 
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436'); 
} 

我也曾嘗試API代碼

FB.init({ 
      appId : 'appid', // application Id 
     status : true, // check login status 
     cookie : true, // enable cookies to allow the server to access the session 
      xfbml : true // parse XFBML 
     }); 
    function publishStream(targetId, name, link, picture, source, userName,message) { 
FB.ui(
     { 
      method: 'feed', 

       name: name, 
       link: link, 
       picture: picture, 
       source: source, // The URL of a media file (e.g., a SWF or video file) attached to this post 
        caption: 'Shared by '+userName, 
       actions: {name: 'Try App', link: link}, 
        message: message 

      }, 
      function(response){ 
      if (response && response.post_id) { 

      } else { 

      } 
     }); 
     } 

,但我不能選擇我的朋友並張貼到他們的牆上。總之,使用這個API,我需要得到像第一個共享者那樣的對話框。

如何在用戶配置文件中播放我的音頻文件?

+1

嗯,你與閃光和惱人的音樂和獨角獸思維的MySpace。 Facebook不會讓你在你的頁面或其他人的頁面上注入隨機垃圾。這是Facebook擊敗MySpace的主要原因 - 它看起來不像一個8歲女孩的大腦在互聯網上嘔吐。 – evan

回答

0

你不能通過發佈在別人的個人資料上播放內容。所有這些代碼使得它看起來像是在創建一個應用程序 - 您的朋友需要首先安裝/提供訪問權限。

更簡單的是在YouTube上找到一個視頻(看起來你在做什麼)。您可以將其發佈到牆上,並自動從用戶的牆上播放(而不是自動播放)。

此功能已經內置於Facebook。沒有必要使用任何代碼。

2

使用共享者URL方法,Facebook在您正在共享的頁面頂部查找一系列Open Graph元標記。這些標籤定義了內容以及Facebook在牆上分享時的內容。

例如,如果你要共享使用JW媒體播放器在您的網站的視頻,你會包括你的頁面上的下列元標記類型:

<meta property="og:title" content="Bits on the Run introduction video"/> 
<meta property="og:description" content="Bits on the Run is a clear and flexible platform 
for transcoding, managing and streaming your video online."/> 
<meta property="og:image" content="http://example.com/thumbs/yYul4DRz-320.jpg" /> 
<meta property="og:site_name" content="http://www.mysite.com" /> 
<meta property="og:type" content="movie"/> 
<meta property="og:url" content="http://example.com/previews/MSO47ORl-tBhZ0fIU"/> 
<meta property="og:video" content="http://example.com/players/yYul4DRz-tBYU3ED4.swf" /> 
<meta property="og:video:height" content="245" /> 
<meta property="og:video:width" content="400" /> 
<meta property="og:video:type" content="application/x-shockwave-flash" /> 

使用例如JW媒體播放器,以及包括您可以通過包含og:image參數來與音頻內容共享音頻元標籤。您正試圖直接共享Youtube視頻,因爲您無法直接訪問網頁,因此您無法修改YouTube上元標記的內容。請使用將Yotube作爲參數並使用音頻文件/ mp3的JW player

以獲取更多信息看這裏:

https://developers.facebook.com/docs/opengraph/

+0

嗨,如何分享一個音頻文件在Facebook使用addthis?請指教我。 – user2003356

相關問題