Files
thetool/scripts/preorder/ofaa-oaid/confirm-single-oaid.php
2023-09-01 11:10:37 +02:00

45 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 = putRestUrl($confirm_url, $headers, ["token" => "confirmed"], "application/json");
if($output == "__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 = putRestUrl($confirm_url, $headers, ["token" => "confirmed"], "application/json");
$u++;
}
echo "$oaid_name confirmed.\n";