如何使用Facebook Graph API上传mp3文件[PHP SDK]

时间:2011-09-28 14:22:44

标签: php facebook-graph-api mp3 publish

我正在使用PHP SDK在Facebook页面上传/发布mp3文件。我有一个wordpress博客,并使用cron作业安排发布。 Cron作业没有问题,除了上传这些mp3文件外,一切似乎都很有效。

我想在我的脸书页面上发布这些帖子的这些mp3文件。 目前我正在使用以下代码。请在附加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);

1 个答案:

答案 0 :(得分: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);