ziggeo / ziggeophpsdk
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.
Installs: 215 388
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 13
Forks: 10
Open Issues: 2
Requires
- php: >=5.3.0
- phpseclib/phpseclib: 2.*
This package is auto-updated.
Last update: 2024-11-04 22:16:25 UTC
README
latest version: 0.1.30
Index
- Why Ziggeo's PHP Server Side SDK?
- Prerequisites
- Client-Side Integration
- Server-Side Integration
- Init
- Available Methods
- Methods for Videos
- Methods for Streams
- Methods for Audios
- Methods for Audio Streams
- Methods for Authtokens
- Methods for Application
- Methods for Effect Profiles
- Methods for Effect Profile Process
- Methods for Meta Profiles
- Methods for Meta Profile Process
- Methods for Webhooks
- Methods for Analytics
- Useful
- License
Why Ziggeo's PHP Server Side SDK?
Ziggeo is a powerfull, whitelabel video SAAS with a goal to help people with their video revolution. And what better way to do it than with an award winning multimedia API.
This server side SDK is designed to help you ease the communication with Ziggeo API. In that it allows you to privately communicate between your server and our server through requests of what you want to happen.
It offers you pre-built functionality to call and manipulate and there are demos in /demos/ directory for you to check out and use as starting point.
Who it is for?
- Do you have a system that requires calls to be made which should not be seen on client side?
- Want to have an easier time handling the media as it comes to your server?
- Want something that is simple and easy to use?
- You need some powerful features high end video services provide?
If any of the above is "Yes" then you are in the right place as this SDK is for you!
Prerequisites
Download
You will want to either download the SDK zip file or to pull it in as git repository into your own project.
To clone it you would go into your project folder and then
php git clone https://github.com/Ziggeo/ZiggeoPhpSdk
How to use
To start using the PHP SDK you would need to initialize the Ziggeo class with application token, private token and possibly encryption token. The token and keys can be found within the Ziggeo application once you log into your account, under Overview page.
Dependencies
If you are using Auth tokens you would need to install PHPSeclib library, at least for the client auth tokens to be created.
If you are using Composer, you would do the following steps:
- Run
composer require phpseclib/phpseclib
within the folder - Edit the Ziggeo.php file and add
require_once 'vendor/autoload.php';
at the very top. -PHPSeclib
Client-Side Integration
For the client-side integration, you need to add these assets to your html file:
<link rel="stylesheet" href="//assets-cdn.ziggeo.com/v2-stable/ziggeo.css" /> <script src="//assets-cdn.ziggeo.com/v2-stable/ziggeo.js"></script>
Then, you need to specify your api token:
<script> var ziggeoApplication = new ZiggeoApi.V2.Application({ token: "APPLICATION_TOKEN", webrtc_streaming_if_necessary: true, webrtc_on_mobile: true }); </script>
You can specify other global options, see here.
To fire up a recorder on your page, add:
<ziggeorecorder></ziggeorecorder>
To embed a player for an existing video, add:
<ziggeoplayer ziggeo-video='video-token'></ziggeoplayer>
For the full documentation, please visit ziggeo.com.
Server-Side Integration
Initialize Ziggeo class in your code
You can integrate the Server SDK as follows:
<?php require_once('./ziggeo/Ziggeo.php'); $ziggeo = new Ziggeo('*token*', '*private_key*', '*encryption_key*', *config*); ?>
Config is optional and if not specified (recommended), the Config file will be used instead.
Available Methods
Currently available methods are branched off within different categories:
- Videos
- Streams
- Audios
- Audio Streams
- Authtokens
- Application
- Effect Profiles
- Effect Profile Process
- Meta Profiles
- Meta Profile Process
- Webhooks
- Analytics
Each of this sections has their own actions and they are explained bellow
Videos
The videos resource allows you to access all single videos. Each video may contain more than one stream.
Index
Query an array of videos (will return at most 50 videos by default). Newest videos come first.
$ziggeo->videos()->index($arguments = array())
Arguments
- limit: Limit the number of returned videos. Can be set up to 100.
- skip: Skip the first [n] entries.
- reverse: Reverse the order in which videos are returned.
- states: Filter videos by state
- tags: Filter the search result to certain tags, encoded as a comma-separated string
Count
Get the video count for the application.
$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.
$ziggeo->videos()->get($token_or_key)
Get Bulk
Get multiple videos by tokens or keys.
$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).
Stats Bulk
Get stats for multiple videos by tokens or keys.
$ziggeo->videos()->stats_bulk($arguments = array())
Arguments
- tokens_or_keys: Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
- summarize: Boolean. Set it to TRUE to get the stats summarized. Set it to FALSE to get the stats for each video in a separate array. Default: TRUE.
Download Video
Download the video data file
$ziggeo->videos()->download_video($token_or_key)
Download Image
Download the image data file
$ziggeo->videos()->download_image($token_or_key)
Get Stats
Get the video's stats
$ziggeo->videos()->get_stats($token_or_key)
Push To Service
Push a video to a provided push service.
$ziggeo->videos()->push_to_service($token_or_key, $arguments = array())
Arguments
- pushservicetoken: Push Services's token (from the Push Services configured for the app)
Apply Effect
Apply an effect profile to a video.
$ziggeo->videos()->apply_effect($token_or_key, $arguments = array())
Arguments
- effectprofiletoken: Effect Profile token (from the Effect Profiles configured for the app)
Apply Meta
Apply a meta profile to a video.
$ziggeo->videos()->apply_meta($token_or_key, $arguments = array())
Arguments
- metaprofiletoken: Meta Profile token (from the Meta Profiles configured for the app)
Update
Update single video by token or key.
$ziggeo->videos()->update($token_or_key, $arguments = array())
Arguments
- min_duration: Minimal duration of video
- max_duration: Maximal duration of video
- tags: Video Tags
- key: Unique (optional) name of video
- volatile: Automatically removed this video if it remains empty
- expiration_days: After how many days will this video be deleted
- expire_on: On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
Update Bulk
Update multiple videos by token or key.
$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
- expire_on: On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
Delete
Delete a single video by token or key.
$ziggeo->videos()->delete($token_or_key)
Create
Create a new video.
$ziggeo->videos()->create($arguments = array())
Arguments
- file: Video file to be uploaded
- min_duration: Minimal duration of video
- max_duration: Maximal duration of video
- tags: Video Tags
- key: Unique (optional) name of video
- volatile: Automatically removed this video if it remains empty
- effect_profile: Set the effect profile that you want to have applied to your video.
- meta_profile: Set the meta profile that you want to have applied to your video once created.
- video_profile: Set the video profile that you want to have applied to your video as you create it.
Analytics
Get analytics for a specific videos with the given params
$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.
Index
Return all streams associated with a video
$ziggeo->streams()->index($video_token_or_key, $arguments = array())
Arguments
- states: Filter streams by state
Get
Get a single stream
$ziggeo->streams()->get($video_token_or_key, $token_or_key)
Download Video
Download the video data associated with the stream
$ziggeo->streams()->download_video($video_token_or_key, $token_or_key)
Download Image
Download the image data associated with the stream
$ziggeo->streams()->download_image($video_token_or_key, $token_or_key)
Push To Service
Push a stream to a provided push service.
$ziggeo->streams()->push_to_service($video_token_or_key, $token_or_key, $arguments = array())
Arguments
- pushservicetoken: Push Services's token (from the Push Services configured for the app)
Delete
Delete the stream
$ziggeo->streams()->delete($video_token_or_key, $token_or_key)
Create
Create a new stream
$ziggeo->streams()->create($video_token_or_key, $arguments = array())
Arguments
- file: Video file to be uploaded
Attach Image
Attaches an image to a new stream. Must be attached before video, since video upload triggers the transcoding job and binds the stream
$ziggeo->streams()->attach_image($video_token_or_key, $token_or_key, $arguments = array())
Arguments
- file: Image file to be attached
Attach Video
Attaches a video to a new stream
$ziggeo->streams()->attach_video($video_token_or_key, $token_or_key, $arguments = array())
Arguments
- file: Video file to be attached
Attach Subtitle
Attaches a subtitle to the stream.
$ziggeo->streams()->attach_subtitle($video_token_or_key, $token_or_key, $arguments = array())
Arguments
- lang: Subtitle language
- label: Subtitle reference
- data: Actual subtitle
Audios
The audios resource allows you to access all single audios. Each video may contain more than one stream.
Index
Query an array of audios (will return at most 50 audios by default). Newest audios come first.
$ziggeo->audios()->index($arguments = array())
Arguments
- limit: Limit the number of returned audios. Can be set up to 100.
- skip: Skip the first [n] entries.
- reverse: Reverse the order in which audios are returned.
- states: Filter audios by state
- tags: Filter the search result to certain tags, encoded as a comma-separated string
Count
Get the audio count for the application.
$ziggeo->audios()->count($arguments = array())
Arguments
- states: Filter audios by state
- tags: Filter the search result to certain tags, encoded as a comma-separated string
Get
Get a single audio by token or key.
$ziggeo->audios()->get($token_or_key)
Get Bulk
Get multiple audios by tokens or keys.
$ziggeo->audios()->get_bulk($arguments = array())
Arguments
- tokens_or_keys: Comma-separated list with the desired audios tokens or keys (Limit: 100 tokens or keys).
Download Audio
Download the audio data file
$ziggeo->audios()->download_audio($token_or_key)
Update
Update single audio by token or key.
$ziggeo->audios()->update($token_or_key, $arguments = array())
Arguments
- min_duration: Minimal duration of audio
- max_duration: Maximal duration of audio
- tags: Audio Tags
- key: Unique (optional) name of audio
- volatile: Automatically removed this audio if it remains empty
- expiration_days: After how many days will this audio be deleted
- expire_on: On which date will this audio be deleted. String in ISO 8601 format: YYYY-MM-DD
Update Bulk
Update multiple audios by token or key.
$ziggeo->audios()->update_bulk($arguments = array())
Arguments
- tokens_or_keys: Comma-separated list with the desired audios tokens or keys (Limit: 100 tokens or keys).
- min_duration: Minimal duration of audio
- max_duration: Maximal duration of audio
- tags: Audio Tags
- volatile: Automatically removed this audio if it remains empty
- expiration_days: After how many days will this audio be deleted
- expire_on: On which date will this audio be deleted. String in ISO 8601 format: YYYY-MM-DD
Delete
Delete a single audio by token or key.
$ziggeo->audios()->delete($token_or_key)
Create
Create a new audio.
$ziggeo->audios()->create($arguments = array())
Arguments
- file: Audio file to be uploaded
- min_duration: Minimal duration of audio
- max_duration: Maximal duration of audio
- tags: Audio Tags
- key: Unique (optional) name of audio
- volatile: Automatically removed this video if it remains empty
Audio Streams
The streams resource allows you to directly access all streams associated with a single audio.
Index
Return all streams associated with a audio
$ziggeo->audioStreams()->index($audio_token_or_key, $arguments = array())
Arguments
- states: Filter streams by state
Get
Get a single stream
$ziggeo->audioStreams()->get($audio_token_or_key, $token_or_key)
Download Audio
Download the audio data associated with the stream
$ziggeo->audioStreams()->download_audio($audio_token_or_key, $token_or_key)
Delete
Delete the stream
$ziggeo->audioStreams()->delete($audio_token_or_key, $token_or_key)
Create
Create a new stream
$ziggeo->audioStreams()->create($audio_token_or_key, $arguments = array())
Arguments
- file: Audio file to be uploaded
Authtokens
The auth token resource allows you to manage authorization settings for video objects.
Get
Get a single auth token by token.
$ziggeo->authtokens()->get($token)
Update
Update single auth token by token.
$ziggeo->authtokens()->update($token_or_key, $arguments = array())
Arguments
- volatile: Will this object automatically be deleted if it remains empty?
- hidden: If hidden, the token cannot be used directly.
- expiration_date: Expiration date for the auth token (Unix epoch time format)
- usage_expiration_time: Expiration time per session (seconds)
- session_limit: Maximal number of sessions
- grants: Permissions this tokens grants
Delete
Delete a single auth token by token.
$ziggeo->authtokens()->delete($token_or_key)
Create
Create a new auth token.
$ziggeo->authtokens()->create($arguments = array())
Arguments
- volatile: Will this object automatically be deleted if it remains empty?
- hidden: If hidden, the token cannot be used directly.
- expiration_date: Expiration date for the auth token (Unix epoch time format)
- usage_expiration_time: Expiration time per session (seconds)
- session_limit: Maximal number of sessions
- grants: Permissions this tokens grants
Application
The application token resource allows you to manage your application.
Get
Read application.
$ziggeo->application()->get()
Update
Update application.
$ziggeo->application()->update($arguments = array())
Arguments
- volatile: Will this object automatically be deleted if it remains empty?
- name: Name of the application
- auth_token_required_for_create: Require auth token for creating videos
- auth_token_required_for_update: Require auth token for updating videos
- auth_token_required_for_read: Require auth token for reading videos
- auth_token_required_for_destroy: Require auth token for deleting videos
- client_can_index_videos: Client is allowed to perform the index operation
- client_cannot_access_unaccepted_videos: Client cannot view unaccepted videos
- enable_video_subpages: Enable hosted video pages
Get Stats
Read application stats
$ziggeo->application()->get_stats($arguments = array())
Arguments
- period: Optional. Can be 'year' or 'month'.
Effect Profiles
The effect profiles resource allows you to access and create effect profiles for your app. Each effect profile may contain one process or more.
Create
Create a new effect profile.
$ziggeo->effectProfiles()->create($arguments = array())
Arguments
- key: Effect profile key.
- title: Effect profile title.
- default_effect: Boolean. If TRUE, sets an effect profile as default. If FALSE, removes the default status for the given effect
Index
Get list of effect profiles.
$ziggeo->effectProfiles()->index($arguments = array())
Arguments
- limit: Limit the number of returned effect profiles. Can be set up to 100.
- skip: Skip the first [n] entries.
- reverse: Reverse the order in which effect profiles are returned.
Get
Get a single effect profile
$ziggeo->effectProfiles()->get($token_or_key)
Delete
Delete the effect profile
$ziggeo->effectProfiles()->delete($token_or_key)
Update
Updates an effect profile.
$ziggeo->effectProfiles()->update($token_or_key, $arguments = array())
Arguments
- default_effect: Boolean. If TRUE, sets an effect profile as default. If FALSE, removes the default status for the given effect
Effect Profile Process
The process resource allows you to directly access all process associated with a single effect profile.
Index
Return all processes associated with a effect profile
$ziggeo->effectProfileProcess()->index($effect_token_or_key, $arguments = array())
Arguments
- states: Filter streams by state
Get
Get a single process
$ziggeo->effectProfileProcess()->get($effect_token_or_key, $token_or_key)
Delete
Delete the process
$ziggeo->effectProfileProcess()->delete($effect_token_or_key, $token_or_key)
Create Filter Process
Create a new filter effect process
$ziggeo->effectProfileProcess()->create_filter_process($effect_token_or_key, $arguments = array())
Arguments
- effect: Effect to be applied in the process
Create Watermark Process
Attaches an image to a new stream
$ziggeo->effectProfileProcess()->create_watermark_process($effect_token_or_key, $arguments = array())
Arguments
- file: Image file to be attached
- vertical_position: Specify the vertical position of your watermark (a value between 0.0 and 1.0)
- horizontal_position: Specify the horizontal position of your watermark (a value between 0.0 and 1.0)
- video_scale: Specify the image scale of your watermark (a value between 0.0 and 1.0)
Edit Watermark Process
Edits an existing watermark process.
$ziggeo->effectProfileProcess()->edit_watermark_process($effect_token_or_key, $token_or_key, $arguments = array())
Arguments
- file: Image file to be attached
- vertical_position: Specify the vertical position of your watermark (a value between 0.0 and 1.0)
- horizontal_position: Specify the horizontal position of your watermark (a value between 0.0 and 1.0)
- video_scale: Specify the image scale of your watermark (a value between 0.0 and 1.0)
Meta Profiles
The meta profiles resource allows you to access and create meta profiles for your app. Each meta profile may contain one process or more.
Create
Create a new meta profile.
$ziggeo->metaProfiles()->create($arguments = array())
Arguments
- key: Meta Profile profile key.
- title: Meta Profile profile title.
Index
Get list of meta profiles.
$ziggeo->metaProfiles()->index($arguments = array())
Arguments
- limit: Limit the number of returned meta profiles. Can be set up to 100.
- skip: Skip the first [n] entries.
- reverse: Reverse the order in which meta profiles are returned.
Get
Get a single meta profile
$ziggeo->metaProfiles()->get($token_or_key)
Delete
Delete the meta profile
$ziggeo->metaProfiles()->delete($token_or_key)
Meta Profile Process
The process resource allows you to directly access all process associated with a single meta profile.
Index
Return all processes associated with a meta profile
$ziggeo->metaProfileProcess()->index($meta_token_or_key)
Get
Get a single process
$ziggeo->metaProfileProcess()->get($meta_token_or_key, $token_or_key)
Delete
Delete the process
$ziggeo->metaProfileProcess()->delete($meta_token_or_key, $token_or_key)
Create Video Analysis Process
Create a new video analysis meta process
$ziggeo->metaProfileProcess()->create_video_analysis_process($meta_token_or_key)
Create Audio Transcription Process
Create a new audio transcription meta process
$ziggeo->metaProfileProcess()->create_audio_transcription_process($meta_token_or_key)
Create Nsfw Process
Create a new nsfw filter meta process
$ziggeo->metaProfileProcess()->create_nsfw_process($meta_token_or_key, $arguments = array())
Arguments
- nsfw_action: One of the following three: approve, reject, nothing.
Create Profanity Process
Create a new profanity filter meta process
$ziggeo->metaProfileProcess()->create_profanity_process($meta_token_or_key, $arguments = array())
Arguments
- profanity_action: One of the following three: approve, reject, nothing.
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.
$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.
Confirm
Confirm a webhook using its ID and the corresponding validation code.
$ziggeo->webhooks()->confirm($arguments = array())
Arguments
- webhook_id: Webhook ID that's returned in the creation call.
- validation_code: Validation code that is sent to the webhook when created.
Delete
Delete a webhook using its URL.
$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
$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
Docker
If you prefer to run this SDK and its demos using Docker, build the image as follows:
docker build . -t ziggeo-php
You can then run demos as follows:
docker run --rm ziggeo-php /ziggeo/demos/list_all_videos.php --token xxx --privatekey xxx
Webhooks
While you technically do not need this SDK to receive webhooks, we have included a demo for your convenience.
Run as follows:
php -S 0.0.0.0:12345 ./demos/webhook-printer.php
If you want to use docker, run as follows:
docker run --rm -p 12345:12345 ziggeo-php php -S 0.0.0.0:12345 /ziggeo/demos/webhook-printer.php
Your local machine needs to be accessible from the internet via port 12345. In most cases, you will be behind a router / NAT, so you will either need to activate some sort of port forwarding or install a local port tunnel like ngrok.
Once such a tunnel is being installed, you can usually tunnel a particular port like 12345 as follows:
ngrok http 12345
The output will then provide you with a particular publicly accessible domain name that you can add to your Ziggeo webhook list:
http://543e13e6.ngrok.io -> localhost:12345
License
Copyright (c) 2013-2022 Ziggeo
Apache 2.0 License