· 9 years ago · Dec 07, 2016, 06:56 AM
1if (isset($_GET['code'])){
2
3 /*POST INFO BACK TO CCP FOR SHIT */
4 $authcode = $_GET['code'];
5
6 $clientid = "2c723a6ced5544068951a005361c114f";
7 $secretkey = "D1JewDmf0EzACaWemONUYdQN0fyp8v6daI1OIIJ4";
8
9 $authheader = base64_encode($clientid.":".$secretkey);
10
11
12 $data = array("grant_type" => "authorization_code", "code" => $authcode);
13 $data_string = '';
14 $url = 'https://login.eveonline.com/oauth/token';
15 $verify_url = 'https://login.eveonline.com/oauth/verify';
16
17 foreach ($data as $key => $value) {
18 $data_string .= $key.'='.$value.'&';
19 }
20
21 rtrim($data_string, '&');
22
23 $ch = curl_init();
24 curl_setopt($ch, CURLOPT_URL, $url);
25 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
26 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
27 curl_setopt($ch, CURLOPT_POST, count($data));
28 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
29 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
30 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
31 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $authheader));
32
33 $result = curl_exec($ch);
34 if ($result===false) {
35 print curl_error($ch);
36 }
37 curl_close($ch);
38 $response=json_decode($result);
39
40 $auth_token=$response->access_token;
41
42 echo "Completed login, auth token recieved<br>";
43 echo "---------------------------------------<br>";
44 echo "Find character name....<br>";
45
46 $ch = curl_init();
47 $header='Authorization: Bearer '.$auth_token;
48 curl_setopt($ch, CURLOPT_URL, $verify_url);
49 curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
50 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
51 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
52 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
53 $result = curl_exec($ch);
54 if ($result===false) {
55 print curl_error($ch);
56 }
57
58 curl_close($ch);
59 $response=json_decode($result);
60 if (!isset($response->CharacterID)) {
61 echo $auth_token;
62 echo '<br>No character ID returned';
63 } else {
64 $charName = $response->CharacterName;
65 $expiresOn = $response->ExpiresOn;
66 echo "<center><h1>Logged on as: " . $charName ."</h1><br>" .
67 "<h2>Expires On: ". $expiresOn ."</h2></center>";
68
69 }
70
71
72
73
74
75 echo "<br><br><br>Client Code: ". $authcode . "<br>Client ID: " . $clientid ."<br>Secret Key: ". $secretkey."<br>AuthHeader encoded: ". $authheader;
76 }
77 else {
78 echo 'Shitters done';
79
80 }