Created
November 11, 2018 12:41
-
-
Save fuzzysteve/392c418ab82adf20fb3cc947fde6dbd9 to your computer and use it in GitHub Desktop.
basic discord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
require 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
$client = new Client(); | |
$code=$_GET['code']; | |
$clientid='nope'; | |
$secret='noway'; | |
$headers=['Authorization'=>'Basic '.base64_encode($clientid.':'.$secret)]; | |
$body=['grant_type'=>'authorization_code','code'=>$code]; | |
$response = $client->request('POST', 'https://login.eveonline.com/oauth/token', ['form_params'=>$body, 'headers'=>$headers]); | |
$json=json_decode($response->getBody()); | |
$access_token=$json->access_token; | |
$headers=['Authorization'=>'Bearer '.$access_token]; | |
$response = $client->request('GET', 'https://esi.tech.ccp.is/verify/', ['headers'=>$headers]); | |
$json=json_decode($response->getBody()); | |
$characterid=$json->CharacterID; | |
$charactername=$json->CharacterName; | |
$response = $client->request('GET', 'https://esi.tech.ccp.is/latest/characters/'.$characterid.'/', ['headers'=>$headers]); | |
$json=json_decode($response->getBody()); | |
$corporationid=$json->corporation_id; | |
$allianceid=-1; | |
if (isset($json->alliance_id)) { | |
$allianceid=$json->alliance_id; | |
} | |
$allianceticker='no alliance'; | |
if ($allianceid) { | |
$response = $client->request('GET', 'https://esi.tech.ccp.is/latest/alliances/'.$allianceid.'/', ['headers'=>$headers]); | |
$json=json_decode($response->getBody()); | |
$allianceticker=$json->ticker; | |
} | |
$_SESSION['characterid']=$characterid; | |
$_SESSION['charactername']=$charactername; | |
$_SESSION['corporationid']=$corporationid; | |
$_SESSION['allianceid']=$allianceid; | |
$_SESSION['allianceticker']=$allianceticker; | |
session_write_close(); | |
$discordclientid="stillno"; | |
$discordcallback="https://www.fuzzwork.co.uk/example/callback2.php"; | |
header('Location: https://discordapp.com/api/oauth2/authorize?response_type=code&client_id='.$discordclientid.'&scope=identify&state=15773059ghq9183habn&redirect_uri='.urlencode($discordcallback)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
require 'vendor/autoload.php'; | |
use GuzzleHttp\Client; | |
$client = new Client(); | |
$code=$_GET['code']; | |
$clientid='nope'; | |
$secret='noway2'; | |
$body=['grant_type'=>'authorization_code','code'=>$code,'client_id'=>$clientid,'client_secret'=>$secret,"redirect_uri"=>'https://www.fuzzwork.co.uk/example/callback2.php']; | |
$response = $client->request('POST', 'https://discordapp.com/api/v6/oauth2/token', ['form_params'=>$body]); | |
$json=json_decode($response->getBody()); | |
$headers=['Authorization'=>'Bearer '.$json->access_token]; | |
$response = $client->request('GET', 'https://discordapp.com/api/v6/users/@me', ['headers'=>$headers]); | |
$json=json_decode($response->getBody()); | |
$username=$json->username; | |
$discriminator=$json->discriminator; | |
print $_SESSION['characterid']."<br>"; | |
print $_SESSION['charactername']."<br>"; | |
print $_SESSION['corporationid']."<br>"; | |
print $_SESSION['allianceid']."<br>"; | |
print $_SESSION['allianceticker']."<br>"; | |
print $username."<br>"; | |
print $discriminator."<br>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$clientid='nope'; | |
header('Location: https://login.eveonline.com/oauth/authorize?response_type=code&redirect_uri='.urlencode('https://www.fuzzwork.co.uk/example/callback.php').'&client_id='.$clientid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment