Download the PHP package climbcoder/opentok without Composer
On this page you can find all versions of the php package climbcoder/opentok. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download climbcoder/opentok
More information about climbcoder/opentok
Files in climbcoder/opentok
Package opentok
Short Description OpenTok is a platform for creating real time streaming video applications, created by TokBox.
License MIT
Homepage https://github.com/opentok/Opentok-PHP-SDK
Informations about the package opentok
OpenTok PHP SDK
The OpenTok PHP SDK lets you generate sessions and tokens for OpenTok applications, and archive sessions. It also includes methods for working with OpenTok archives, working with OpenTok SIP interconnect, and disconnecting clients from sessions.
Installation
Composer (recommended):
Composer helps manage dependencies for PHP projects. Find more info here: http://getcomposer.org
Add this package (opentok/opentok
) to your composer.json
file, or just run the following at the
command line:
Usage
Initializing
This package follows the PSR-4 autoloading standard. If you are using composer to install, you just require the generated autoloader:
Once the files of the SDK are loaded, you initialize an OpenTok\OpenTok
object with your own API
Key and API Secret.
Initialization Options
The OpenTok\OpenTok
object just allow for some overrides of values when special needs arise, such as
needing to point to a different datacenter or change the timeout of the underlying HTTP client. For
these situations, you can pass an array of additional options as the third parameter.
We allow the following options:
apiUrl
- Change the domain that the SDK points to. Useful when needing to select a specific datacenter or point to a mock version of the API for testingclient
- Custom API client that inherits fromOpenTok\Utils\Client
, useful for customizing an HTTP clienttimeout
- Change the default HTTP timeout, which defaults to forever. You can pass a number of seconds to change the timeout.
Creating Sessions
To create an OpenTok Session, use the createSession($options)
method of the
OpenTok\OpenTok
class. The $options
parameter is an optional array used to specify the following:
-
Setting whether the session will use the OpenTok Media Router or attempt to send streams directly between clients.
-
Setting whether the session will automatically create archives (implies use of routed session)
- Specifying a location hint.
The getSessionId()
method of the OpenTok\Session
instance returns the session ID,
which you use to identify the session in the OpenTok client libraries.
Generating Tokens
Once a Session is created, you can start generating Tokens for clients to use when connecting to it.
You can generate a token either by calling the generateToken($sessionId, $options)
method of the
OpenTok\OpenTok
class, or by calling the generateToken($options)
method on the OpenTok\Session
instance after creating it. The $options
parameter is an optional array used to set the role,
expire time, and connection data of the Token. For layout control in archives and broadcasts,
the initial layout class list of streams published from connections using this token can be set as well.
Working with Streams
You can get information about a stream by calling the getStream($sessionId, $streamId)
method of the
OpenTok\OpenTok
class.
You can get information about all the streams in a session by calling the listStreams($sessionId)
method of the
OpenTok\OpenTok
class.
Working with Archives
You can only archive sessions that use the OpenTok Media Router (sessions with the media mode set to routed).
You can start the recording of an OpenTok Session using the startArchive($sessionId, $name)
method
of the OpenTok\OpenTok
class. This will return an OpenTok\Archive
instance. The parameter
$archiveOptions
is an optional array and is used to assign a name, whether to record audio and/or
video, the desired output mode for the Archive, and the desired resolution if applicable. Note that you can only start an
Archive on a Session that has clients connected.
If you set the outputMode
option to OutputMode::INDIVIDUAL
, it causes each stream in the archive to be recorded to its own individual file. Please note that you cannot specify the resolution when you set the outputMode
option to OutputMode::INDIVIDUAL
. The OutputMode::COMPOSED
setting (the default) causes all streams in the archive to be recorded to a single (composed) file.
Note that you can also create an automatically archived session, by passing in ArchiveMode::ALWAYS
as the archiveMode
key of the options
parameter passed into the OpenTok->createSession()
method (see "Creating Sessions," above).
You can stop the recording of a started archive using the stopArchive($archiveId)
method of the
OpenTok\OpenTok
object. You can also do this using the stop()
method of the
OpenTok\Archive
instance.
To get an OpenTok\Archive
instance (and all the information about it) from an archive ID, use the
getArchive($archiveId)
method of the OpenTok\OpenTok
class.
To delete an Archive, you can call the deleteArchive($archiveId)
method of the OpenTok\OpenTok
class or the delete()
method of an OpenTok\Archive
instance.
You can also get a list of all the Archives you've created (up to 1000) with your API Key. This is
done using the listArchives($offset, $count, $sessionId)
method of the OpenTok/OpenTok
class. The parameters
$offset
, $count
, and $sessionId
are optional and can help you paginate through the results, and subset the
data by a specific session. This will return an instance of the OpenTok\ArchiveList
class.
For composed archives, you can change the layout dynamically, using the setArchiveLayout($archiveId, $layoutType)
method:
You can set the initial layout class for a client's streams by setting the layout
option when
you create the token for the client, using the OpenTok->generateToken()
method or the
Session->generateToken()
method. And you can change the layout classes for a stream
by calling the OpenTok->updateStream()
method.
Setting the layout of composed archives is optional. By default, composed archives use the "best fit" layout (see Customizing the video layout for composed archives).
For more information on archiving, see the OpenTok archiving developer guide.
Working with Broadcasts
You can only start live streaming broadcasts for sessions that use the OpenTok Media Router (sessions with the media mode set to routed).
Start the live streaming broadcast of an OpenTok Session using the
startBroadcast($sessionId, $options)
method of the OpenTok\OpenTok
class.
This will return an OpenTok\Broadcast
instance. The $options
parameter is
an optional array used to assign broadcast options such as layout, maxDuration, resolution, and more.
You can stop the live streaming broadcast using the stopBroadcast($broadcastId)
method of the
OpenTok\OpenTok
object. You can also do this using the stop()
method of the
OpenTok\Broadcast
instance.
To get an OpenTok\Broadcast
instance (and all the information about it) from a broadcast ID,
use the getBroadcast($broadcastId)
method of the OpenTok\OpenTok
class.
You can set change the layout dynamically, using the
OpenTok->updateBroadcastLayout($broadcastId, $layout)
method:
You can use the Layout
class to set the layout types:
Layout::getHorizontalPresentation()
, Layout::getVerticalPresentation()
, Layout::getPIP()
,
Layout::getBestFit()
, Layout::createCustom()
.
You can also set the Screenshare Layout by calling the setScreenshareType()
method on a layout object.
You can set the initial layout class for a client's streams by setting the layout
option when
you create the token for the client, using the OpenTok->generateToken()
method or the
Session->generateToken()
method. And you can change the layout classes for a stream
by calling the OpenTok->updateStream()
method.
Setting the layout of live streaming broadcasts is optional. By default, broadcasts use the "best fit" layout (see Configuring video layout for OpenTok live streaming broadcasts).
For more information on live streaming broadcasts, see the OpenTok live streaming broadcasts developer guide.
Force a Client to Disconnect
Your application server can disconnect a client from an OpenTok session by calling the forceDisconnect($sessionId, $connectionId)
method of the OpenTok\OpenTok
class.
Sending Signals
Once a Session is created, you can send signals to everyone in the session or to a specific connection.
You can send a signal by calling the signal($sessionId, $payload, $connectionId)
method of the
OpenTok\OpenTok
class.
The $sessionId
parameter is the session ID of the session.
The $payload
parameter is an associative array used to set the
following:
-
data
(string) -- The data string for the signal. You can send a maximum of 8kB. type
(string) -- — (Optional) The type string for the signal. You can send a maximum of 128 characters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '_', and '~'.
The $connectionId
parameter is an optional string used to specify the connection ID of
a client connected to the session. If you specify this value, the signal is sent to
the specified client. Otherwise, the signal is sent to all clients connected to the session.
For more information, see the OpenTok signaling developer guide.
Working with SIP Interconnect
You can add an audio-only stream from an external third-party SIP gateway using the SIP Interconnect feature. This requires a SIP URI, the session ID you wish to add the audio-only stream to, and a token to connect to that session ID.
To initiate a SIP call, call the dial($sessionId, $token, $sipUri, $options)
method of the
OpenTok\OpenTok
class:
For more information, see the OpenTok SIP Interconnect developer guide.
Force Disconnect
Your application server can disconnect a client from an OpenTok session by calling the forceDisconnect($sessionId, $connectionId)
method of the OpenTok\OpenTok
class.
Sending Signals
Once a Session is created, you can send signals to everyone in the session or to a specific connection.
You can send a signal by calling the signal($sessionId, $payload, $connectionId)
method of the
OpenTok\OpenTok
class.
The $sessionId
parameter is the session ID of the session.
The $payload
parameter is an associative array used to set the
following:
-
data
(string) -- The data string for the signal. You can send a maximum of 8kB. type
(string) -- — (Optional) The type string for the signal. You can send a maximum of 128 characters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '_', and '~'.
The $connectionId
parameter is an optional string used to specify the connection ID of
a client connected to the session. If you specify this value, the signal is sent to
the specified client. Otherwise, the signal is sent to all clients connected to the session.
For more information, see the OpenTok signaling developer guide.
Samples
There are three sample applications included in this repository. To get going as fast as possible, clone the whole repository and follow the Walkthroughs:
- HelloWorld
- Archiving
- SipCall
Documentation
Reference documentation is available at https://tokbox.com/developer/sdks/php/reference/index.html.
Requirements
You need an OpenTok API key and API secret, which you can obtain by logging into your TokBox account.
The OpenTok PHP SDK requires PHP 7.2 or higher.
Release Notes
See the Releases page for details about each release.
Important changes since v2.2.0
Changes in v2.2.1:
The default setting for the createSession()
method is to create a session with the media mode set
to relayed. In previous versions of the SDK, the default setting was to use the OpenTok Media Router
(media mode set to routed). In a relayed session, clients will attempt to send streams directly
between each other (peer-to-peer); if clients cannot connect due to firewall restrictions, the
session uses the OpenTok TURN server to relay audio-video streams.
Changes in v2.2.0:
This version of the SDK includes support for working with OpenTok archives.
The names of many methods of the API have changed. Many method names have changed to use camel case, including the following:
\OpenTok\OpenTok->createSession()
\OpenTok\OpenTok->generateToken()
Note also that the options
parameter of the OpenTok->createSession()
method has a mediaMode
property instead of a p2p
property.
The API_Config class has been removed. Store your OpenTok API key and API secret in code outside of the SDK files.
See the reference documentation http://www.tokbox.com/opentok/libraries/server/php/reference/index.html and in the docs directory of the SDK.
Development and Contributing
Interested in contributing? We :heart: pull requests! See the Development and Contribution guidelines.
Getting Help
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository
- See https://support.tokbox.com/ for support options
- Tweet at us! We're @VonageDev on Twitter
- Or join the Vonage Developer Community Slack
All versions of opentok with dependencies
ext-xml Version *
johnstevenson/json-works Version ~1.1
firebase/php-jwt Version ^5.0
guzzlehttp/guzzle Version ~6.0|~7.0