lucisgit / php-panopto-api
PHP Panopto API client and libraries.
Installs: 1 459
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 5
Forks: 1
Open Issues: 2
Requires
- php: ^8.0
- ext-soap: *
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-09 19:09:35 UTC
README
This is PHP5 implementation of Panopto v4.6 API. It contains client class for accessing Panopto API public webservices and corresponding libarary classes for performing the API calls. The client is composer/autoload friendly.
All public Panopto v4.6 API webservices are supported, i.e.
AccessManagement
, Auth
, RemoteRecorderManagement
,
SessionManagement
, UsageReporting
and UserManagement
.
Features
- Includes types classes.
- Identity Provider authentication support.
- Follows PSR-4 conventions and autoload friendly.
- Provides client class for simplifying individual webservices access
- Provides script for generating library classes for custom host/version.
API documentation
Use web or standalone version of documentation published on its offical website: https://support.panopto.com/articles/Documentation/api-0
Including library using autoload
php-panopto-api
is using Composer. This is the
most convenient way to start using it in your project.
If you are starting from scratch, download composer first:
$ curl -s http://getcomposer.org/installer | php
Then run the command to require the library:
$ php composer.phar require lucisgit/php-panopto-api
At this stage you should be able to include the library in your project:
<?php // This file is generated by Composer require_once 'vendor/autoload.php';
Including library directly
Alternatively, you may clone/download content of php-panopto-api
repo and
place in in subdirectory of your project. In this case you may include
library directly:
<?php // php-panopto-api content has been placed in `lib/panopto` sub-directory. require_once(dirname(__FILE__) . "/lib/panopto/lib/Client.php");
Usage
Using client class instance simplifies accessing Panopto webservices and authentication process. At minimum, you need to know your server hostname and user credentials. Depending on the type of call you want to make, your user may require specific role. Check API documentation for details.
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; // Create client instance for my.panopto.host. $panoptoclient = new \Panopto\Client('my.panopto.host'); // Create AuthenticationInfo instance with user crdentials. $panoptoclient->setAuthenticationInfo('username', 'userpassword'); // Get AuthenticationInfo instance for using in calls. $auth = $panoptoclient->getAuthenticationInfo(); // For example, get RemoteRecorderManagement webservice instance for // accessing its methods. $rrmclient = $panoptoclient->RemoteRecorderManagement(); // Let's list recorders for this simple example. According to API docs we need // Pagination instance. $page = 1; $perpage = 10; $pagination = new \Panopto\RemoteRecorderManagement\Pagination(); $pagination->setPageNumber($page); $pagination->setMaxNumberResults($perpage); // Prepare ListRecorders parameter instance, sort recorders by 'Name'. $param = new \Panopto\RemoteRecorderManagement\ListRecorders($auth, $pagination, 'Name'); // Perform API call, this return value of ListRecordersResponse type. try { $recorderslist = $rrmclient->ListRecorders($param)->getListRecordersResult(); } catch(Exception $e) { throw new SoapFault('client', $e->getMessage()); } echo "Total recorders count: " . $recorderslist->TotalResultCount; // Iterate through the list of recorders, each recorder is represented as // RemoteRecorder type, see API docs for supported properties. $recorders = $recorderslist->PagedResults->getRemoteRecorder(); foreach($recorders as $recorder) { echo "Recorder name: " . $recorder->getName(); echo "Recorder IP: " . $recorder->getMachineIP(); // Get devices, each device is represented as RemoteRecorderDevice type, // see API docs for supported properties. $devices = $recorder->getDevices()->getRemoteRecorderDevice(); foreach($devices as $device) { echo "Device: " . $device->getDeviceType() . ': ' . $device->getName(); } }
You can find some other examples how client can be used in the
examples
directory.
Authentication using Application Key
You can create AuthenticationInfo instance using Application Key value from
Identity Provider setting in Panopto. You do not need a password in this
case, however the username needs to be preceed with corresponding Instance
Name, e.g. MyInstanceName\username
. It makes sense to use this feature
where the client is used in the application that supposed to be linked to Panopto.
// Create client instance for my.panopto.host. $panoptoclient = new \Panopto\Client('my.panopto.host'); // Create AuthenticationInfo instance with user crdentials. $panoptoclient->setAuthenticationInfo('MyInstanceName\username', '', '00000000-0000-0000-0000-000000000000'); // Get AuthenticationInfo instance for using in calls. $auth = $panoptoclient->getAuthenticationInfo();
Building custom library classes
The repo includes script for generating library classes using wsdl2phpgenerator converter and Panopto WSDL interface endpoints. This can be used for making library up to date with upstream changes or generating classes for the host-specific API version.
How to setup
You need a clone of this repo and install dependencies using Composer first.
$ pwd /home/user/git $ git clone https://github.com/lucisgit/php-panopto-api.git Cloning into 'php-panopto-api'... remote: Counting objects: 368, done. remote: Compressing objects: 100% (5/5), done. remote: Total 368 (delta 0), reused 0 (delta 0), pack-reused 363 Receiving objects: 100% (368/368), 104.24 KiB | 0 bytes/s, done. Resolving deltas: 100% (238/238), done. Checking connectivity... done. $ cd php-panopto-api $ curl -s http://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.4.1) successfully installed to: /home/ruslan/git/php-panopto-api/composer.phar Use it: php composer.phar $ php composer.phar install Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 3 installs, 0 updates, 0 removals - Installing symfony/polyfill-iconv (v1.3.0): Loading from cache - Installing symfony/options-resolver (v3.2.6): Loading from cache - Installing wsdl2phpgenerator/wsdl2phpgenerator (3.4.0): Loading from cache Generating autoload files
How to use
By default, the script is using demo.hosted.panopto.com and version 4.6, but you can specify alternative host/version for your own needs (run command with -h parameter for usage details).
$ php generate_phpclasses.php Using https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/ for webservices interface. Generating \Panopto\AccessManagement classes... Generating \Panopto\Auth classes... Generating \Panopto\RemoteRecorderManagement classes... Generating \Panopto\SessionManagement classes... Generating \Panopto\UsageReporting classes... Generating \Panopto\UserManagement classes... PHP classess have been generated from Panopto API WSDL. Use /home/user/git/php-panopto-api/lib/Panopto/PublicAPI/4.6/<webservice>/autoload.php in your project.