Skip to content

Instantly share code, notes, and snippets.

@vibhavsinha
Created November 4, 2016 05:49
Show Gist options
  • Save vibhavsinha/bd253f150d9350aa463ef67dd6adfcb3 to your computer and use it in GitHub Desktop.
Save vibhavsinha/bd253f150d9350aa463ef67dd6adfcb3 to your computer and use it in GitHub Desktop.
Sample php implementation of the new API
<?php
class VdoCipherApi {
private static $APIKEY = "API_SECRET_KEY"; // replace with api key
public function vdoApi($method, $action, $params = [], $post_data = []) {
$ch = curl_init("http://dev.vdocipher.com/api");
$url = "https://dev.vdocipher.com/api" . $action;
if (count($params) > 0) {
$url .= '?' . http_build_query($params);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if ($method === "POST" || $method === "PUT") {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
}
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Authorization: Apisecret " . self::$APIKEY;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $result;
}
}
$result = VdoCipherApi::vdoApi('GET' , '/videos', ['page' => 2]);
print_r(json_decode($result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment