Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $standingsRes = $client->get($endpoint, $standings_headers);
- $standingsResp = json_decode($standingsRes->getBody());
- if(count($standingsResp > 0)) {
- $factionStandings = array();
- $corpStandings = array();
- foreach($standingsResp as $st) {
- if($st->from_type == 'faction') {
- $ret = Faction::where('faction_id', $st->from_id)->first();
- array_push($factionStandings, array('from_id' => $st->from_id, 'from_type' => $st->from_type, 'faction_name' => $ret->faction_name, 'standing' => $st->standing));
- } elseif($st->from_type == 'npc_corp') {
- $retC = NpcCorp::where('corp_id', $st->from_id)->first();
- if(!isset($retC->corp_name)) {
- $endpoint = "https://esi.tech.ccp.is/latest/corporations/$st->from_id";
- $corp_headers = [
- 'headers' => [
- 'User-Agent' => env('USERAGENT'),
- ],
- 'query' => [
- 'datasource' => 'tranquility',
- ]
- ];
- $corpRes = $client->get($endpoint, $corp_headers);
- $corpResp = json_decode($corpRes->getBody());
- $newCorp = new NpcCorp;
- $newCorp->corp_id = $st->from_id;
- $newCorp->corp_name = $corpResp->name;
- $newCorp->save();
- array_push($corpStandings, array('from_type' => $st->from_type, 'standing' => $st->standing, 'from_id' => $st->from_id, 'name' => $corpResp->name));
- } else {
- array_push($corpStandings, array('from_type' => $st->from_type, 'standing' => $st->standing, 'from_id' => $st->from_id, 'name' => $retC->corp_name));
- }
- } else {
- //Don't care about Agents for now
- continue;
- }
- }
- }
- $resp->{'factionStandings'} = $factionStandings;
- $resp->{'corpStandings'} = $corpStandings;
- }
Advertisement
Add Comment
Please, Sign In to add comment