Snitch Ashor
Black Rise Guerilla Forces The Bloc
6
|
Posted - 2017.03.07 08:56:12 -
[2] - Quote
This is a part of my sso class that might help you. Its based on Steves script. Once I got the code i use this to get a token:
public function setCode($code) { $this->code = $code;
$url = 'https://login.eveonline.com/oauth/token'; $header = 'Authorization: Basic '.base64_encode($this->config['evesso_clientid'].':'.$this->config['evesso_code']); $fields_string = ''; $fields = array( 'grant_type' => 'authorization_code', 'code' => $code, ); foreach ($fields as $key => $value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, self::$userAgent); curl_setopt($ch, CURLOPT_HTTPHEADER, array($header)); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $result = curl_exec($ch); if ($result === false) { $this->error = true; $this->message = (curl_error($ch)); } curl_close($ch); if (!$this->error){ $response = json_decode($result); $this->accessToken = $response->access_token; $this->expires = (strtotime("now")+1000); $this->refreshToken = $response->refresh_token; $result = $this->verify(); return $result; } else { return false; } }
In the last step i call verify, which then gives you characterid and name:
public function verify() { if (!isset($this->accessToken)) { $this->error = true; $this->message = "No Acess Token to verify."; return false; } else { $verify_url = 'https://login.eveonline.com/oauth/verify'; $ch = curl_init(); $header = 'Authorization: Bearer '.$this->accessToken; curl_setopt($ch, CURLOPT_URL, $verify_url); curl_setopt($ch, CURLOPT_USERAGENT, self::$userAgent); curl_setopt($ch, CURLOPT_HTTPHEADER, array($header)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $result = curl_exec($ch); if ($result === false) { $this->error = true; $this->message = (curl_error($ch)); } curl_close($ch); if ($this->error) { return false; } $response = json_decode($result); if (isset($response->error)) { $this->error = true; $this->message = $response->error; &nb...
|