0

我正在尝试将视频上传到 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"}}"

看起来我添加号召性用语的方式不正确。但我真的不知道如何解决它。

4

1 回答 1

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;
于 2016-02-19T10:02:03.237 回答