Created
October 10, 2013 15:44
-
-
Save Noahii/6920557 to your computer and use it in GitHub Desktop.
BF4 battlelog JSON stats thing for PHP
This file contains 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 | |
//Self Explanatory \ | |
$postchars = http_build_query(array( | |
'redirect' => '', | |
'email' => '[email protected]', | |
'password' => 'wdfaqwgaf', | |
'submit' => 'Log+in' | |
), '', '&'); | |
$ckfile = tempnam ("/tmp", "COOKIES"); | |
$ch = curl_init('https://battlelog.battlefield.com/bf4/gate/login/'); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Expect:', | |
'User-Agent: ' . 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0', | |
'Accept: */*', | |
'Accept-Language: en-us,en;q=0.5', | |
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7' | |
)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $postchars); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_exec($ch); | |
curl_close($ch); | |
//--------------------------------------------------------------\ user ID / http://noahi.me/ongxy | |
$ch = curl_init("http://battlelog.battlefield.com/bf4/indexstats/349400632/1/?stats=1"); | |
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Expect:', | |
'User-Agent: ' . 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0', | |
'Accept: */*', | |
'Accept-Language: en-us,en;q=0.5', | |
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7', | |
'X-Requested-With: XMLHttpRequest', | |
'X-AjaxNavigation: 1' | |
)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_ENCODING, "gzip"); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
$json = json_decode($data); | |
//Layout etc http://noahi.me/ynfap | |
$stats = $json['data']['generalPersonaStats']; | |
echo $stats['skill'] . " skill</br>"; | |
echo $stats['kdRatio'] . " kdRatio</br>"; | |
echo $stats['kills'] . " kills</br>"; | |
echo $stats['score'] . " score</br>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment