2011-09-28 76 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);