2011-09-28 75 views
2

我正在使用PHP SDK在Facebook頁面上載/發佈mp3文件。我有一個WordPress博客,並使用cron作業安排發佈。 Cron的工作沒有問題,除了上傳這些mp3文件外,一切似乎都很好。如何使用Facebook Graph API上傳mp3文件[PHP SDK]

我想發佈這些MP3文件與我的Facebook頁面上的這些帖子。 目前我正在使用下面的代碼。請附上我附加MP3文件時出錯的地方。 我已經嘗試從附件參數中刪除「媒體」。

$args = array(
'access_token' => $post_access_token, 
'uid' => $fb_page_id, 
'message' => $post->post_title, 
'name' => $post->post_title, 
'caption' => get_bloginfo('name'), 
'link' => get_permalink($post_id), 
'picture' => urldecode(get_post_meta($post_id, 'image_value', true)), 
'description' => $this->auto_make_excerpt($post->post_content), 
'attachment' => json_encode(array(
    "media" => 
    array(
     'type' => 'mp3', 
     "src" => urlencode("http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"), 
     "title" => "15 Step", 
     "artist" => "Radiohead", 
     "album" => "In Rainbows" 
    ) 
)), 
'actions' => json_encode(array(
    array(
     'name' => 'Share', 
     'link' => 'http://www.facebook.com/sharer.php?u='.urlencode(get_permalink($post_id)).'&t='.$post->post_title 
    ) 
)) 
);$responseId = $this->facebook->api('/'.$fb_page_id.'/feed', 'POST', $args); 

回答

0
"src" => urlencode("http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3"), 

的網址已被編碼。再次嘗試對網址進行編碼...您可以更改並重試嗎?

嘗試下面的代碼發佈文件在FB

$attachment = array('type' => 'mp3', 
     "src" => "http://www.looptvandfilm.com/blog/Radiohead%20-%20In%20Rainbows/01%20-%20Radiohead%20-%2015%20Step.MP3", 
     "title" => "15 Step", 
     "artist" => "Radiohead", 
     "album" => "In Rainbows" 


$result = $facebook->api('/'. $fb_id . '/feed/', 
          'post', 
          $attachment);