Top Left Text cha

Web & App Development

function callAPI($method, $url, $data){
   $curl = curl_init();

   switch ($method){
      case "POST":
         curl_setopt($curl, CURLOPT_POST, 1);
         if ($data)
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
      case "PUT":
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
         if ($data)
            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);			 					
         if ($data)
            $url = sprintf("%s?%s", $url, http_build_query($data));

   // OPTIONS:
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_HTTPHEADER, array(
      'APIKEY: 111111111111111111111',
      'Content-Type: application/json',
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

   // EXECUTE:
   $result = curl_exec($curl);
   if(!$result){die("Connection Failure");}
   return $result;

Thanks/Credits: Weichie Projects

lso, if you do this to avoid having to install a PHP library, etc. to use Vimeo's tut approach, you would normally still have to go through all those hoops just to get the thumbnail.  You can't get the thumbnail like you can on other services like Youtube.  For some [stupid] reason, they use a completely different ID for the thumbnail.  My first attempt at using the video ID to display the thumbnail resulted in a thumb of a porn video. Nice crap job, Vimeo. Anyway, I found a post for a workaround for getting the Vimeo thumbs without having to do all that work.

Add comment

Security code

  • No comments found

Leave your comments

Post comment as a guest

Your comments are subjected to administrator's moderation.