如何使用PHP通过图形API发布视频至Facebook [英] How to POST video to Facebook through Graph API using PHP
本文介绍了如何使用PHP通过图形API发布视频至Facebook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在文档中找到的code使用<形式方法=POST
张贴到个人资料视频:
The code found in the documentation uses a <form method="POST"
to post a video to a profile:
// Using the page access token from above, create the POST action
// that our form will use to upload the video.
$post_url = "https://graph-video.facebook.com/" . $page_id . "/videos?"
. "title=" . $video_title. "&description=" . $video_desc
. "&access_token=". $access_token;
// Create a simple form
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>';
什么是从URL后,无需使用形式干净的方式?
What's the cleanest way to post from a URL without using a form?
推荐答案
假设你已经上传了视频服务器上...
Assuming that you have already uploaded the video on your server...
$config = array();
$config['appId'] = 'appID';
$config['secret'] = 'secretID';
$config['fileUpload'] = true;
$config['cookie'] = true;
$facebook = new Facebook($config);
$facebook->setFileUploadSupport(true);
$video_details = array(
'access_token'=> 'user publish token',
'message'=> 'Test video!',
'source'=> '@' .realpath($videosPathOnServer)
);
$post_video = $facebook->api('/'.$usersFacebookID.'/videos', 'post', $video_details);
据我记得,默认情况下所有视频可见性设置为朋友和他们的朋友
As far as I remember, by default all videos visibility is set to Friends and their Friends
这篇关于如何使用PHP通过图形API发布视频至Facebook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文