Using PHP to access UsageReporting SOAP API
I work in our Data Warehouse group and we are trying to access usage statistics from Panopto Videos. I've seen the examples of accessing the SOAP APIs in Python, but we don't have anyone with Python skills available to us. I have written several PHP processes to access APIs, including SOAP. I created a rather simple example of calling the 'DescribeReportTypes' function since it's only parameter is the Authentication Info. I appear to be able to access the API, but get this message when I run my code:
PHP Fatal error: Uncaught SoapFault exception: [s:Client] "Unable to authenticate the user."
Here is the simple PHP code I am using:
<?php
define('ENDPOINT','https://xxxx.hosted.panopto.com/Panopto/PublicAPI/4.0/UsageReporting.svc?singleWsdl');
define('USERNAME','username');
define('PASSWORD','password');
$client = new SoapClient(ENDPOINT);
$params = array('AuthCode' => '', 'Password' => PASSWORD, 'UserKey' => USERNAME);
$result = $client->DescribeReportTypes($params);
vardump($result);
?>
I'm not sure if the Authentication Info is being passed correctly or if there's a problem with the username/password in Panopto. I also created a Client API, so I have a Client Name, Id, and Secret if that can be used to access UsageReportiing.
Any assistance would be greatly appreciated.
Thanks,
Bob
Answers
Hey Bob,
The params for the Authenticationfo would need to be wrapped into another object with a parameter called 'auth'
Also is the user you are trying to make this call from an internal user or an external user associated with an Identity Provider?
If the user is an external user one thing it could be is are you properly prefacing the userkey with the instance name of the provider the user is associated with? The name being placed in the userKey should look like <instance>\<userName>, e.g. "moodle39\joe.smith". External Users also require an AuthCode and can not be authenticated with a password.
If the user in an internal user then the only thing I can ask is that you verify the username and password are correct for the user?
Thanks,
Joe
Joe,
Thanks for your assistance. I did the following and now I can get the results of DescribeReportTypes:
$params = array();
$params['auth'] = array('AuthCode' => '', 'Password' => PASSWORD, 'UserKey' => USERNAME);
$result = $client->DescribeReportTypes($params);
Bob