SetStartStatus(); //Get the esi config $config = config('esi'); //Declare some variables $charId = $config['primary']; $corpId = 98287666; $sHelper = new StructureHelper($charId, $corpId); $structures = null; //ESI Scope Check $esiHelper = new Esi; $structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1'); $corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1'); //Check scopes if($structureScope == false || $corpStructureScope == false) { if($structureScope == false) { Log::critical("Scope check for esi-universe.read_structures.v1 has failed."); } if($corpStructureScope == false) { Log::critical("Scope check for esi-corporations.read_structures.v1 has failed."); } return null; } //Get the refresh token from the database $token = $esiHelper->GetRefreshToken($charId); //Create the esi authentication container $esi = $esiHelper->SetupEsiAuthentication($token); //Set the current page $currentPage = 1; //Set our default total pages, and we will refresh this later $totalPages = 1; //Try to get the ESI data try { $structures = $esi->page($currentPage) ->invoke('get', '/corporations/{corporation_id}/structures/', [ 'corporation_id' => $corpId, ]); } catch (RequestFailedException $e) { Log::critical("Failed to get structure list."); return null; } $totalPages = $structures->pages; for($i = 1; $i <= $totalPages; $i++) { ProcessStructureJob::dispatch($charId, $corpId, $currentPage)->onQueue('structures'); } //Mark the job as finished $task->SetStopStatus(); } }