Include Call to Action in Facebook Video Upload to Page - Graph API -


I have the following work codes for video upload for 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 "More details =". $ Video_desc "& Amp; ACCESS_TOKEN =". $ ACCESS_TOKEN; $ Ch = curl_init (); $ Data = array ('name' = & gt; 'file', 'file' = & gt; '@'. Actual path ($ file)); // Use the real path 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 take action to request, which is the document.

I tried the following:

  $ Fb_action = Stratouper ($ the_action); $ Fb_action_link = $ action_link; $ Call_to_action = "& amp; 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." And Details = ". $ Video_desc $ Call_to_action" & Amp; ACCESS_TOKEN = ". $ ACCESS_TOKEN;  

And I also tried:

  $ call_to_action =" & amp; Call_to_action = ['type', ''. $ Fb_action '', 'Value', ['Click', ''. $ Fb_action_link. " ']] ";  

I immediately keep an error from Facebook, does anyone know that this is a formatting problem? Any suggestion for the right way? Very much appreciated!

Then this issue was actually formatting of arrays. I found that http_build_query () was a solution that is obviously How the Facebook developers change their parameters to encode this post helped me a lot ->

The final solution Yes:

$ string_only = '$ string_in' = ' Params = http_build_query (array ('call_to_action' => $ action_call_array)); $ Post_url = 'https://graph-video.facebook.com/' .ff_page_id. '/ Video?'. 'Title =' $ Video_title . '& Amp; Description =' $ Video_desc '& Amp;' Urldecode ($ params) '& amp; ACCP; ACCESS_TOKEN ='. $ M_page_access_token;

Plug $ post_url into the curl and works great! Hope it helps someone , I took a little time to find and test the correct answer, and it seems that this solution will work with the array in Parameters for other Facebook endpoint.


Comments