开发者

Uploading video to Facebook album

开发者 https://www.devze.com 2023-04-01 04:41 出处:网络
I\'ve created a开发者_开发百科 Facebook album and have the album ID.I\'m able to upload a photo to the album using the /photos API.But I can\'t upload a video using something like /videos API.I get th

I've created a开发者_开发百科 Facebook album and have the album ID. I'm able to upload a photo to the album using the /photos API. But I can't upload a video using something like /videos API. I get the error message:

"(#200) User does not have permission to post to target"

1) Is that even a supported API call? I couldn't find much on Facebook's developer site on this. 2) Is it a permission flag problem? I have publish_stream, photo_upload, video_upload, user_photos, user_videos all requested. I don't know if photo_upload/video_upload are even proper ones, but saw examples from other sites about photo_upload so I just assumed there might be a video_upload.


yes, you can upload video.

Make sure you are posting to a place where u get permission to do so. You can see an example with code at http://developers.facebook.com/blog/post/493/

code extracted below:

<?php 
$app_id = "YOUR_APP_ID";
$app_secret = "YOUR_APP_SECRET"; 
$my_url = "YOUR_POST_LOGIN_URL"; 
$video_title = "YOUR_VIDEO_TITLE";
$video_desc = "YOUR_VIDEO_DESCRIPTION";

$code = $_REQUEST["code"];

if(empty($code)) {
   $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" 
     . $app_id . "&redirect_uri=" . urlencode($my_url) 
     . "&scope=publish_stream";
    echo("<script>top.location.href='" . $dialog_url . "'</script>");
}

$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
    . $app_id . "&redirect_uri=" . urlencode($my_url) 
    . "&client_secret=" . $app_secret 
    . "&code=" . $code;
$access_token = file_get_contents($token_url);

$post_url = "https://graph-video.facebook.com/me/videos?"
    . "title=" . $video_title. "&description=" . $video_desc 
    . "&". $access_token;

echo '<form enctype="multipart/form-data" action=" '.$post_url.' "  
     method="POST">';
echo 'Please choose a file:';
echo '<input name="file" type="file">';
echo '<input type="submit" value="Upload" />';
echo '</form>';
?>
0

精彩评论

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