Skip to content

Commit

Permalink
Auto Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfriedmann committed May 12, 2018
1 parent 274b305 commit b6ad104
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor
*.sh
110 changes: 109 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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*





Expand Down
15 changes: 15 additions & 0 deletions classes/ZiggeoAnalytics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

Class ZiggeoAnalytics {

protected $application;

function __construct($application) {
$this->application = $application;
}

function get($data = array()) {
return $this->application->connect()->postJSON('/analytics/get', $data);
}

}
16 changes: 16 additions & 0 deletions classes/ZiggeoVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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 . '');
}
Expand All @@ -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);
}

}
19 changes: 19 additions & 0 deletions classes/ZiggeoWebhooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

Class ZiggeoWebhooks {

protected $application;

function __construct($application) {
$this->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);
}

}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions demos/download_video.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions demos/video_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
));

0 comments on commit b6ad104

Please sign in to comment.