Download the PHP package sproutvideo/sproutvideo without Composer
On this page you can find all versions of the php package sproutvideo/sproutvideo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sproutvideo/sproutvideo
More information about sproutvideo/sproutvideo
Files in sproutvideo/sproutvideo
Package sproutvideo
Short Description A PHP client for SproutVideo (https://sproutvideo.com)
License BSD-4-Clause
Homepage https://sproutvideo.com
Informations about the package sproutvideo
SproutVideo
Use this library to interact with the SproutVideo API
Installation
Install with Composer
If you're using Composer to manage dependencies, you can add SproutVideo with.
Composer will take care of the autoloading for you, so if you require the vendor/autoload.php, you're good to go.
Install source from GitHub
To install the source code:
$ git clone git://github.com/sproutvideo/sproutvideo-php.git
And including it using the autoloader:
Getting Started
The first thing you'll need to interact with the SproutVideo API is your API key.
Videos
The following methods are available: list_videos
, get_video
, create_video
, update_video
, replace_video
, delete_video
.
list_videos
By default the videos listing is paginated with 25 videos per page and sorted by upload date in ascending order. You can pass two parameters to control the paging: page and per_page. You can also pass in the id of a tag to just return the videos tagged with that tag.
get_video
The string passed to get_video is the ID of a SproutVideo video.
create_video
The most basic upload you can perform is to just pass the path to the video file to the method. The title of the video will default to the name of the file.
You can set the title as well as many other parameters by passing them as a array
You can also apply any number of tags to the new upload by passing their ids along:
You can also create and apply tags on the fly when uploading by passing along tag names:
You can also specify a webhook url. We'll send an HTTP POST with the video json when the video has finished processing or if there was an error during processing:
Lastly, if you are using the source_video_url
parameter instead of uploading a file directly, use the following syntax:
update_video
The first parameter is the id of the video you wish to edit. The second parameter is a array of attributes to update on the video.
replace_video
The first parameter is the id of the video you wish to replace. The second parameter is the local path to the video file.
Tags
To add a tag to a video, make sure to include all of the tags currently associated with the video. For instance, if the video already has tags with the ids "abc" and "123", and you want to add a tag with the id "def", pass "abc", "123" and "def" to the update method.
If you want to remove a tag from a video, remove the tag from the list of tags on the video but make sure to include all of the tags you wish to keep. For instance, if you now want to remove the tag with id "123" from the example above, pass in "abc" and "def"
You can remove all of the tags from a video by just passing an empty array as the tags parameter.
Upload poster frame
You can upload a custom poster frame for a video by calling the upload_poster_frame method. The first parameter is the id of the video for wish you'd like the poster frame to be associated and the second parameter is the path to the image file.
delete_video
Pass in the id of the video you wish to delete.
Signed Embed Codes
You can use this convenience method to sign an embed code. It will return the embed code URL which can be used to build an iframe embed code.
Parameters
video_id - String ( Required ) : The id of the video for which you're generating the signed embed code
security_token - String ( Required ) : The security token of the video for which you're generatingn the signed embed code
query_parameteres - Array ( Optional )
: A array of query parameters to be passed to the embed code. Example: array('type' => 'hd', 'autoplay' => 'true')
expiration_time - Integer ( Optional ) : The number of seconds from the Epoc that this signed embed code should expire. This defaults to 5 minutes from the time the signed embed code was generated.
protocol - String ( Optional )
: http
or https
. Defaults to http
Examples
Upload Tokens
The following methods are available: create_upload_token
create_upload_token
Live Streams
The following methods are available: list_live_streams
, create_live_stream
, get_live_stream
, update_live_stream
, delete_live_stream
, end_live_stream
upload_poster_frame
.
list_live_streams
By default the live_stream listing is paginated with 25 live_streams per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
get_live_stream
create_live_stream
update_live_stream
delete_live_stream
Pass in the id of the live_stream you wish to delete.
end_live_stream
Pass in the id of the live_stream you wish to end.
Tags
The following methods are available: list_tags
, create_tag
, get_tag
, update_tag
, delete_tag
.
list_tags
By default the tag listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
get_tag
create_tag
update_tag
delete_tag
Pass in the id of the tag you wish to delete.
Folders
The following methods are avaialble: list_folders
, create_folder
, get_folder
, update_folder
, delete_folder
list_folders
By default, the folder listing is paginated with 25 folders per page and sorted by created_at
date in ascending order. You can pass tow parameters to control the paging: page
and per_page
. If you do not pass in a parent_id
only the folders within the root folder will be returned. To get the folders in a specific folder, make sure to pass in that folder's id using the parent_id
parameter.
create_folder
Creating a folder without a parent_id
will place that folder in the root folder. Passing in a parent_id
will place the newly created folder in the folder specified by parent_id
.
get_folder
update_folder
delete_folder
By default, when deleting a folder, all of the contents of that folder (videos and folders), will be moved the root folder to prevent unintended data loss. If you wish to actually delete all of the content of a folder, make sure to pass in delete_all
as true.
Playlists
The following methods are available: list_playlists
, create_playlist
, get_playlsit
, update_playlist
, delete_playlist
.
list_playlists
By default, the playlist listing is paginated with 25 playlists per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
create_playlist
You can add videos to a playlist when creating it by passing in the videos you'd like to add in the videos parameter in the order you'd like them to appear.
update_playlist
videos
To add a video to a playlist, make sure to include all of the videos currently associated with that playlist. For instance if the playlist already has videos with the ids "abc" and "123" and you want to add a video with the id "def" do pass "abc", "123" and "def" to the update method.
If you want to remove a video from a playlist, remove the video from the list of videos in the playlist but make sure to include all of the videos you wish to keep. For instance, if you now want to remove the video with id "123" from the example above, pass in "abc" and "def"
You can remove all of the videos from a playlist by just passing an empty array as the videos parameter.
delete_playlist
Pass in the id of the playlist you wish to delete.
Logins
The following methods are available: list_logins
, create_login
, get_login
, update_login
, delete_login
list
By default the login listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
create_login
create_login takes two required parameters, email
and password
, which will be used to allow a viewer to login to watch a video if the login has an associated access_grant
for that video.
get_login
The string passed to get_login is the ID of a SproutVideo login.
update_login
You can change the password for a login.
delete_login
Pass in the id of the login you wish to delete.
Access Grants
The following methods are available: list_access_grants
, create_access_grant
, get_access_grant
, update_acces_grant
, delete_access_grant
list_access_grants
By default the access grant listing is paginated with 25 tags per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page.
create_access_grant
create_access_grant takes two required parameters, video_id
and login_id
, which will be used to allow a viewer to login to watch a video based on the other optional parameters.
bulk_create_access_grants
bulk_create_access_grants takes an array of access grant objects and creates them in a single API call to efficiently create access grants in bulk, and reduce the number of API calls needed.
get_access_grant
The string passed to get_access_grant is the ID of a SproutVideo login.
update_access_grant
You can change the optional parameters for an access grant.
delete_access_grant
Pass in the id of the access grant you wish to delete.
Analytics
The following methods are available through the API client for analytics:
- play_counts
- domains
- geo
- video_types
- playback types
- device_types
Check the API documentation for more information about the data returned by these calls.
Each method can be called on it's own for overall account data for all time like this:
Each method can also take an options array containing a :video_id for retrieving overall data for a specific video:
The following methods can also take an options array containing a :live for retrieving overall data for a specific video:
Each method can also take an optional :start_date and :end_date to specify a date range for the returned data:
The geo method can take an optional :country to retrieve playback data by city within that country
misc analytics endpoints
Engagement
You can grab the total number of seconds of your videos that have been watched like this:
And for livestreams:
You can grab engagement for a specific video like so:
And for a livestream:
Lastly, you can grab every single playback session for a video like this:
You can also grab engagement sessions for a video for a specific email address like so:
You can also grab engagement sessions for a live stream:
Account
The following methods are available: get_account
, update_account
.
get_account
update_account
Subtitles
The following methods are available: list_subtitles
, create_subtitle
, get_subtitle
, update_subtitle
, delete_subtitle
.
list_subtitles
By default, the subtitle listing is paginated with 25 subtitles per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page. You must pass a video_id in the options array.
create_subtitle
To create a subtitle, you must pass the following data
: language and content. You must also pass the video_id
option for the video you want to add the subtitle to.
update_subtitle
delete_subtitle
Pass in the id of the subtitle you wish to delete and it's associated video_id.
Calls to Action
The following methods are available: list_ctas
, create_cta
, get_cta
, update_cta
, delete_cta
.
list_ctas
By default, the cta listing is paginated with 25 ctas per page and sorted by created at date in ascending order. You can pass two parameters to control the paging: page and per_page. You must pass a video_id in the options array.
create_cta
To create a cta, you must pass the following data
: text, url, start_time, and end_time. You must also pass the video_id
option for the video you want to add the cta to.
update_cta
delete_cta
Pass in the id of the cta you wish to delete and it's associated video_id.
Contributing to sproutvideo-php
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
- Fork the project.
- Start a feature/bugfix branch.
- Commit and push until you are happy with your contribution.
Setup
- download deps by running
composer install
- run the test suite by running
./vendor/bin/phpunit tests
Copyright
Copyright (c) 2021 SproutVideo. See LICENSE.txt for further details.