Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Route::get('esitoken', function () {
- $url = 'https://login.eveonline.com/oauth/token';
- $data = array('grant_type' => 'authorization_code', 'code' => $_GET['code']);
- $clientID = '';
- $secretKey = '';
- $options = array(
- 'http' => array(
- 'header' => "Authorization: Basic ". base64_encode($clientID .':'. $secretKey) ."\r\nContent-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'POST',
- 'content' => http_build_query($data),
- ),
- );
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- $responce = json_decode($result);
- $url = 'https://login.eveonline.com/oauth/verify';
- $data = array('grant_type' => 'authorization_code', 'code' => $_GET['code']);
- $options = array(
- 'http' => array(
- 'header' => "Authorization: Bearer ". $responce->access_token ."\r\nContent-type: application/x-www-form-urlencoded\r\n",
- 'method' => 'GET',
- 'content' => http_build_query($data),
- ),
- );
- $context = stream_context_create($options);
- $result = file_get_contents($url, false, $context);
- $tokeninfo = json_decode($result);
- die(print_r($tokeninfo));
- $header = 'Authorization: Basic ' . base64_encode($clientID . ':' . $secretKey);
- $fields_string = '';
- $fields = array(
- 'grant_type' => 'authorization_code',
- 'code' => $_GET['code']
- );
- foreach ($fields as $key => $value) {
- $fields_string .= $key . '=' . $value . '&';
- }
- rtrim($fields_string, '&');
- $ch = curl_init();
- curl_setopt_array(
- $ch,
- array(
- CURLOPT_URL => 'https://login.eveonline.com/oauth/token',
- CURLOPT_POST => true,
- CURLOPT_POSTFIELDS => $fields_string,
- CURLOPT_HTTPHEADER => array($header),
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_USERAGENT => 'Ch3ss/0.1b',
- CURLOPT_SSL_VERIFYPEER => true,
- CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1,
- )
- );
- $resBody = curl_exec($ch);
- $info = curl_getinfo($ch);
- $err = curl_errno($ch);
- $errmsg = curl_error($ch);
- if ($err != 0)
- throw new Exception($errmsg, $err);
- if (!in_array($info['http_code'], array(200, 302)))
- throw new Exception(
- 'HTTP response not OK: ' . (int)$info['http_code'] . '. Response body: ' . $resBody,
- $info['http_code']
- );
- curl_close($ch);
- $response = json_decode($resBody);
- print_r($tokeninfo);
- print_r($response);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement