#!/usr/bin/php $tenant, "version" => "v8", ]; //var_dump($content); if(count($argv) > 1) { $batch_size = intval($argv[1]); } if(!$batch_size) { die("Batchsize not defined!\n"); } $c = 0; $u = 0; echo "Creating and confirming $batch_size version ".$content['version']." OAIDs for tenant ".$content['tenant']."\n"; for($i = 0; $i < $batch_size; $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($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 = putRestUrl($confirm_url, $headers, ["token" => "confirmed"], "application/json"); } echo "."; $u++; } } echo "Created $c, confirmed $u\n";