Wettmannstaetten impot update & ofaa oaid scripts
This commit is contained in:
+79
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once __DIR__."/include/config.php";
|
||||
require_once __DIR__."/include/rest.php";
|
||||
|
||||
|
||||
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",
|
||||
];
|
||||
|
||||
$content = [
|
||||
"tenant" => $tenant,
|
||||
"version" => "v8",
|
||||
];
|
||||
var_dump($content);
|
||||
|
||||
$c = 0;
|
||||
$u = 0;
|
||||
|
||||
for($i = 0; $i < 621; $i++) {
|
||||
$content['external_id'] = guidv4();
|
||||
|
||||
$output = postRestUrl($ep_request_oaid, $headers, $content, "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",
|
||||
];
|
||||
$output = postRestUrl($ep_request_oaid, $headers, $content, "application/json");
|
||||
}
|
||||
|
||||
//var_dump($output);exit;
|
||||
$output_json = json_decode($output);
|
||||
|
||||
if(!is_object($output_json)) {
|
||||
//var_dump($output);
|
||||
echo "Output not JSON Object\n";
|
||||
continue;
|
||||
}
|
||||
$c++;
|
||||
|
||||
$oaid = $output_json->oaid;
|
||||
$tenant = $output_json->tenant;
|
||||
$token = $output_json->token;
|
||||
$status = $output_json->status;
|
||||
$external_id = $output_json->external_id;
|
||||
|
||||
//echo "oaid: $oaid, tenant: $tenant, token: $token, status: $status, external_id: $external_id\n";
|
||||
|
||||
if($token == "requested") {
|
||||
$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 ".";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo "Created $c, confirmed $u\n";
|
||||
Reference in New Issue
Block a user