-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate_phpclasses.php
104 lines (77 loc) · 2.97 KB
/
generate_phpclasses.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/*
* Panopto PHP classes generator.
*
* This script is using WSDL to PHP classes converter tool
* (https://github.com/wsdl2phpgenerator/wsdl2phpgenerator) to
* generate PHP classess for Panopto API web services use.
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
die; // no access from web!
}
if (file_exists(__DIR__.'/vendor/autoload.php')) {
require_once(__DIR__.'/vendor/autoload.php');
$generator = new \Wsdl2PhpGenerator\Generator();
} else {
echo "Composer dependencies seem missing, run 'php composer.phar install' in the current directory.\n";
die;
}
// Set defaults.
$server = 'demo.hosted.panopto.com';
$version = '4.6';
// CLI options.
$options = getopt("h", array('host:', 'apiversion:', 'help'));
// Checking util.php CLI script usage.
$help = <<<HELP
Panopto PHP classes generator.
This script is generating PHP classess for Panopto API web services using WSDL interface.
Usage:
php generate_phpclasses.php [-h|--help] [--host=value] [--apiversion=value]
Options:
--host Hostname to use for WSDL endpoints (default: $server).
--apiversion API version to use (default: $version).
-h, --help Print out this help
Example usage:
\$ php generate_phpclasses.php --host=panopto.host.org --apiversion=4.6
The above command will generate PHP classes in ./lib/Panopto/PublicAPI/4.6/ directory.
HELP;
// Read CLI options.
if (isset($options['help']) || isset($options['h'])) {
echo $help;
exit(0);
}
if (!empty($options['host'])) {
$server = $options['host'];
}
if (!empty($options['apiversion'])) {
$version = $options['apiversion'];
}
// Generate classes.
$destination = __DIR__.'/lib/Panopto/PublicAPI/' . $version;
$webservices = array(
'AccessManagement',
'Auth',
'RemoteRecorderManagement',
'SessionManagement',
'UsageReporting',
'UserManagement',
);
echo 'Using https://' . $server . '/Panopto/PublicAPI/' . $version . "/ for webservices interface.\n";
foreach ($webservices as $webservice) {
echo "Generating \Panopto\\" . $webservice . " classes...\n";
$generatorconfig = array(
'inputFile' => 'https://' . $server . '/Panopto/PublicAPI/' . $version . '/' . $webservice . '.svc?wsdl',
'outputDir' => $destination . '/' . $webservice,
'namespaceName' => 'Panopto\\' . $webservice,
);
$generator->generate(new \Wsdl2PhpGenerator\Config($generatorconfig));
}
// Display version of the server.
require_once($destination . '/Auth/autoload.php');
$wsdl = 'https://' . $server . '/Panopto/PublicAPI/' . $version . '/Auth.svc?wsdl';
$authclient = new \Panopto\Auth\Auth(array(), $wsdl);
$param = new \Panopto\Auth\GetServerVersion();
$version = $authclient->GetServerVersion($param)->getGetServerVersionResult();
echo "\nServer $server is running Panopto version ${version}\n";
echo "\nPHP classess have been sucessfully generated using Panopto API WSDL. Use " . $destination . "/<webservice>/autoload.php in your project. Check Readme file for more information on usage.\n";
exit(0);