44 lines
1.0 KiB
PHP
Executable File
44 lines
1.0 KiB
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
require_once __DIR__."/include/config.php";
|
|
require_once __DIR__."/include/rest.php";
|
|
|
|
$oaid = false;
|
|
|
|
if(count($argv) > 1) {
|
|
$oaid = $argv[1];
|
|
}
|
|
|
|
if(!$oaid) {
|
|
die("OAID name required\n");
|
|
}
|
|
|
|
if(!$access_token) {
|
|
$access_token = fetchAccessToken($oauth_url, $client_id, $client_secret, $default_scope);
|
|
if(!$access_token) {
|
|
die("Error getting access token");
|
|
}
|
|
}
|
|
|
|
$headers = [
|
|
"Authorization: Bearer $access_token",
|
|
"Accept: application/json",
|
|
"Content-type: application/json",
|
|
];
|
|
|
|
$confirm_url = str_replace("{oaid}", $oaid, $ep_confirm_oaid);
|
|
$out = patchRestUrl($confirm_url, $headers, ["token" => "confirmed"], "application/json");
|
|
if($out == "__err__401") {
|
|
$access_token = fetchAccessToken($oauth_url, $client_id, $client_secret, $default_scope);
|
|
$headers = [
|
|
"Authorization: Bearer $access_token",
|
|
"Accept: application/json",
|
|
"Content-type: application/json",
|
|
];
|
|
$out = patchRestUrl($confirm_url, $headers, ["token" => "confirmed"], "application/json");
|
|
}
|
|
|
|
echo "$oaid confirmed.\n";
|
|
|
|
|