New PHP Library for Accessing the Wowza Streaming Engine REST APIDecember 28, 2016
When leveraging the Wowza Streaming Engine REST API, figuring out where to start can be a daunting task. With this in mind, we've developed a small PHP library wrapper for the Wowza Streaming Engine REST API. You can download it, install it, and use the example scripts (and build on them) to get off on the right foot in building a solution for your use case.
The installation provides examples similar to the ones in our article called How to use cURL to query the Wowza Streaming Engine REST API, but using a PHP library (that also leverages cURL). You will find examples for each of the following topics:
- Publisher access
- Application creation and management
- Stream file management
- Server and application statistics
- User creation and management
- Stream targets (push publishing map entries)
- SMIL files
- nDVR clip extraction
Most of the functionality is then accessible through just a few lines of code. For instance, to create a stream file you can call the create function on the StreamFile object, and you're on your way to ingesting a stream into your Wowza server instance via the REST API, as follows:
$request = new comwowzaStreamFile(“live”, “newstream”);
$response = $request->create(array(“uri”=>”rtsp://localhost/my/source/stream”,”streamTimeout”=>1200), “rtp”);
The resulting stream file includes the specified URI along with a stream timeout of 1200 milliseconds. To further illustrate its simplicity, you can then connect to that stream:
$response = $request->connect();
And, of course, disconnect from it:
$response = $request->disconnect();
This basic PHP wrapper library is also very easily extendable, as the library objects are laid out within the lib folder and modification is quickly done within it.
For more on using the Wowza Streaming Engine REST API, watch our REST API developer webinar on demand.