It's possible to upload a movie via php sdk?
How can i do it?
i tried something like $facebook->api('/me/movies','POST开发者_StackOverflow',array('source'=>..));
but it didn't worked.
see this howto: http://developers.facebook.com/blog/post/493/
Accessing /me/movies is a list of the movies that the user likes. Things that the user likes are not editable via the Facebook Graph API. If you are trying to upload a movie file, you would use /me/videos.
Here's a proper solution. You need the access token from somewhere. In my case I get it into another moment. And I upload the video when the user is offline.
require 'php-sdk/src/facebook.php';
.
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
));
$facebook->setAccessToken("myaccesstokenhere");
$facebook->setFileUploadSupport(true);
$args = array('title' => 'The title of the video','description'=>'The description of the video');
$args['videoData'] = '@' . realpath($_SERVER['DOCUMENT_ROOT']."/uploads/video.mp4");
try {
$data = $facebook->api('/me/videos', 'post', $args);
} catch (FacebookApiException $e) {
echo "result=ERROR&message=".$e->getMessage();
die();
}
精彩评论