开发者

How to upload mp3 file using Facebook Graph API [PHP SDK]

I am using PHP SDK to upload/publish mp3 file on facebook page. I have a wordpress blog and using cron jobs to schedule post. Cron job has no issue and everything seems to be working great except uploading these mp3 files.

I want to publish these mp3 files with those posts on my facebook page. Currently i am using the following code. Please suggest where am i going wrong while attaching mp3 files. I have already tried removing "media" from attachment parameter.

$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),
'pictur开发者_开发知识库e' => 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);


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

the url is already encoded. Again you try to encode the url ... can you change that and try again?

Try the following code to post File in 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜