diff --git a/.gitignore b/.gitignore index 22d0d82..e69ee15 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ vendor +*.sh diff --git a/README.md b/README.md index b7aebda..ad9e2d0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ziggeo PHP Server SDK 0.1.0 +# Ziggeo PHP Server SDK 0.1.2 Ziggeo API (https://ziggeo.com) allows you to integrate video recording and playback with only two lines of code in your site, service or app. This is the PHP Server SDK repository. @@ -112,6 +112,19 @@ Arguments - tags: *Filter the search result to certain tags, encoded as a comma-separated string* +#### Count + +Get the video count for the application. + +```php +$ziggeo->videos()->count($arguments = array()) +``` + +Arguments +- states: *Filter videos by state* +- tags: *Filter the search result to certain tags, encoded as a comma-separated string* + + #### Get Get a single video by token or key. @@ -122,6 +135,18 @@ $ziggeo->videos()->get($token_or_key) +#### Get Bulk + +Get multiple videos by tokens or keys. + +```php +$ziggeo->videos()->get_bulk($arguments = array()) +``` + +Arguments +- tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).* + + #### Download Video Download the video data file @@ -183,6 +208,23 @@ Arguments - expiration_days: *After how many days will this video be deleted* +#### Update Bulk + +Update multiple videos by token or key. + +```php +$ziggeo->videos()->update_bulk($arguments = array()) +``` + +Arguments +- tokens_or_keys: *Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).* +- min_duration: *Minimal duration of video* +- max_duration: *Maximal duration of video* +- tags: *Video Tags* +- volatile: *Automatically removed this video if it remains empty* +- expiration_days: *After how many days will this video be deleted* + + #### Delete Delete a single video by token or key. @@ -210,6 +252,21 @@ Arguments - volatile: *Automatically removed this video if it remains empty* +#### Analytics + +Get analytics for a specific videos with the given params + +```php +$ziggeo->videos()->analytics($token_or_key, $arguments = array()) +``` + +Arguments +- from: *A UNIX timestamp in microseconds used as the start date of the query* +- to: *A UNIX timestamp in microseconds used as the end date of the query* +- date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.* +- query: *The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser* + + ### Streams The streams resource allows you to directly access all streams associated with a single video. @@ -500,6 +557,57 @@ Arguments - scale: *Specify the image scale of your watermark (a value between 0.0 and 1.0)* +### Webhooks + +The webhooks resource allows you to create or delete webhooks related to a given application. + + +#### Create + +Create a new webhook for the given url to catch the given events. + +```php +$ziggeo->webhooks()->create($arguments = array()) +``` + +Arguments +- target_url: *The url that will catch the events* +- encoding: *Data encoding to be used by the webhook to send the events.* +- events: *Comma-separated list of the events the webhook will catch. They must be valid webhook type events.* + + +#### Delete + +Delete a webhook using its URL. + +```php +$ziggeo->webhooks()->delete($arguments = array()) +``` + +Arguments +- target_url: *The url that will catch the events* + + +### Analytics + +The analytics resource allows you to access the analytics for the given application + + +#### Get + +Get analytics for the given params + +```php +$ziggeo->analytics()->get($arguments = array()) +``` + +Arguments +- from: *A UNIX timestamp in microseconds used as the start date of the query* +- to: *A UNIX timestamp in microseconds used as the end date of the query* +- date: *A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.* +- query: *The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser* + + diff --git a/classes/ZiggeoAnalytics.php b/classes/ZiggeoAnalytics.php new file mode 100644 index 0000000..c0336c7 --- /dev/null +++ b/classes/ZiggeoAnalytics.php @@ -0,0 +1,15 @@ +application = $application; + } + + function get($data = array()) { + return $this->application->connect()->postJSON('/analytics/get', $data); + } + +} \ No newline at end of file diff --git a/classes/ZiggeoVideos.php b/classes/ZiggeoVideos.php index 08d99e9..94aeddd 100644 --- a/classes/ZiggeoVideos.php +++ b/classes/ZiggeoVideos.php @@ -12,10 +12,18 @@ function index($data = array()) { return $this->application->connect()->getJSON('/videos/', $data); } + function count($data = array()) { + return $this->application->connect()->getJSON('/videos/count', $data); + } + function get($token_or_key) { return $this->application->connect()->getJSON('/videos/' . $token_or_key . ''); } + function get_bulk($data = array()) { + return $this->application->connect()->postJSON('/videos/get_bulk', $data); + } + function download_video($token_or_key) { return $this->application->connect()->get('/videos/' . $token_or_key . '/video'); } @@ -36,6 +44,10 @@ function update($token_or_key, $data = array()) { return $this->application->connect()->postJSON('/videos/' . $token_or_key . '', $data); } + function update_bulk($data = array()) { + return $this->application->connect()->postJSON('/videos/update_bulk', $data); + } + function delete($token_or_key) { return $this->application->connect()->delete('/videos/' . $token_or_key . ''); } @@ -46,4 +58,8 @@ function create($data = array()) { return $this->application->connect()->postJSON('/videos/', $data); } + function analytics($token_or_key, $data = array()) { + return $this->application->connect()->postJSON('/videos/' . $token_or_key . '/analytics', $data); + } + } \ No newline at end of file diff --git a/classes/ZiggeoWebhooks.php b/classes/ZiggeoWebhooks.php new file mode 100644 index 0000000..8d95f23 --- /dev/null +++ b/classes/ZiggeoWebhooks.php @@ -0,0 +1,19 @@ +application = $application; + } + + function create($data = array()) { + return $this->application->connect()->post('/api/hook', $data); + } + + function delete($data = array()) { + return $this->application->connect()->post('/api/removehook', $data); + } + +} \ No newline at end of file diff --git a/composer.json b/composer.json index 9f94de3..f938f7c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ziggeo/ziggeophpsdk", "description": "Ziggeo API (https://ziggeo.com) allows you to integrate video recording and playback with only two lines of code in your site, service or app.", - "version": "0.1.0", + "version": "0.1.2", "license": "Apache-2.0", "require" : { "php": ">=5.3.0", diff --git a/demos/download_video.php b/demos/download_video.php index c28f28f..5f0b2a3 100644 --- a/demos/download_video.php +++ b/demos/download_video.php @@ -5,14 +5,14 @@ */ require_once(dirname(__FILE__) . "/../Ziggeo.php"); -$opts = getopt("", array("token:", "privatekey:", "video:")); +$opts = getopt("", array("token:", "privatekey:", "video:", "filename:")); $ziggeo = new Ziggeo($opts["token"], $opts["privatekey"]); $video = $ziggeo->videos()->get($opts["video"]); $file_extension = $video->original_stream->video_type; -$file_name = $video->original_stream->video_token.".".$file_extension; +$file_name = @$opts["filename"] ? $opts["filename"] : $video->original_stream->video_token.".".$file_extension; $file_content = $ziggeo->videos()->download_video($video->original_stream->video_token) ; file_put_contents($file_name, $file_content); diff --git a/demos/video_upload.php b/demos/video_upload.php index 21d852c..0500dd0 100644 --- a/demos/video_upload.php +++ b/demos/video_upload.php @@ -2,10 +2,11 @@ require_once(dirname(__FILE__) . "/../Ziggeo.php"); -$opts = getopt("", array("token:", "privatekey:", "file:")); +$opts = getopt("", array("token:", "privatekey:", "file:", "key:")); $ziggeo = new Ziggeo($opts["token"], $opts["privatekey"]); $ziggeo->videos()->create(array( - "file" => $opts["file"] + "file" => $opts["file"], + "key" => $opts["key"] ));