I have the following working code for video upload to a Facebook page Timeline:
$file = $my_video;
$video_title = $my_title;
$video_desc = $my_description;
$post_url = "https://graph-video.facebook.com/".$fb_page_id."/videos?"
. "title=" . $video_title. "&description=" . $video_desc
. "&access_token=". $access_token;
$ch = curl_init();
$data = array('name' => 'file', 'file' => '@'.realpath($file));// use realpath
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($ch);
curl_close($ch);
$video_id = $res['id'];
I would like to add a call to action to the request, which is documented here from Facebook.
I tried the following:
$fb_action = strtoupper($the_action);
$fb_action_link = $action_link;
$call_to_action = "&call_to_action={'type':'".$fb_action."','value':{'link':'".$fb_action_link."'}}";
$post_url = "https://graph-video.facebook.com/".$fb_page_id."/videos?"
. "title=" . $video_title. "&description=" . $video_desc . $call_to_action
. "&access_token=". $access_token;
And I also tried:
$call_to_action = "&call_to_action=['type','".$fb_action."','value',['link','".$fb_action_link."']]";
I keep getting an error back immediately from Facebook. Does anyone know if this is a formatting issue? Any suggestions for the proper way? Hugely appreciated !