我正在尝试将视频上传到Facebook页面作为页面管理员,并发出号召性用语:
// Post Data
$action_call_array = array('type' => 'LEARN_MORE', 'value' => array('link' => 'http://www.google.com'));
$data = [
'title' => 'Demo Title',
'description' => 'Demo Description
http://www.google.com
http://hk.yahoo.com',
'source' => new CURLFile('video/video_1mb.mp4', 'video/mp4'),
'call_to_action' => $action_call_array,
'access_token' => FACEBOOK_PAGE_TOKEN, // MUST BE INCLUDED !!!
];
// Post Url
$post_url = 'https://graph-video.facebook.com/'.FACEBOOK_PAGE_ID.'/videos';
// CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);
// result
$j = json_decode($return);
$page_post_id = $j->id;
var_dump($return);
没有号召性用语,它就有效。但在添加调用操作后,它会返回以下错误:
string(196) "{"error":{"type":"Exception","message":"No Call To Action Type was parseable. Please refer to the call to action api documentation","code":1373054,"is_transient":false,"fbtrace_id":"H9GksxYBdQx"}}"
看起来我添加号召性用语的方式不正确。但我真的不知道如何解决它。
答案 0 :(得分:0)
我将调用操作放入url参数中,它现在正在运行!
// Post Data
$fb_action = 'LEARN_MORE';
$fb_action_link = 'http://www.google.com';
$action_call_array = array('type' => $fb_action, 'value' => array('link' => $fb_action_link));
$params = http_build_query(array('call_to_action' => $action_call_array));
$data = [
'title' => 'Demo Title',
'description' => 'Demo Description
http://www.google.com
http://hk.yahoo.com',
'source' => new CURLFile('video/video_1mb.mp4', 'video/mp4'),
'access_token' => FACEBOOK_PAGE_TOKEN, // MUST BE INCLUDED !!!
];
// Post Url
$post_url = 'https://graph-video.facebook.com/'.FACEBOOK_PAGE_ID.'/videos?'.urldecode($params);
// CURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($ch);
curl_close($ch);
// result
$j = json_decode($return);
$page_post_id = $j->id;