|
You last visited: Today at 00:37
Advertisement
SpeedAPI
Discussion on SpeedAPI within the Need for Speed World forum part of the Other Online Games category.
09/30/2014, 10:47
|
#1
|
elite*gold: 0
Join Date: Apr 2013
Posts: 368
Received Thanks: 53
|
SpeedAPI
Any coders out there that can give me a little help. I am trying to get leaderboard data but it seems the world servers only keep data within the last ~2-3 months. Anything earlier when I make a request it returns an empty xml result.
Does anybody know if they keep data further than 3 months and I am just post requesting incorrectly, or that is how it is. And if they only have partial data, does anybody know of a way I can get older data?
Thanks in advance. I included my post request below.
my post request is of the form:
http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards?et=$mpsp&eid=$eventid[0]<=$timeframe&rf=$time&dn=$name&shard=$server
for lt=3 (week) rf=28 (28th week of this year) to rf=40 (this week), any earlier and i get empty results.
|
|
|
09/30/2014, 17:09
|
#2
|
elite*gold: 15
Join Date: Aug 2012
Posts: 3,041
Received Thanks: 6,397
|
Is that AutoIT or AutoHotkey?
|
|
|
09/30/2014, 17:33
|
#3
|
elite*gold: 0
Join Date: Jul 2012
Posts: 210
Received Thanks: 41
|
Quote:
Originally Posted by berkay2578
Is that AutoIT or AutoHotkey?
|
SpeedAPI is nor autoIT nor it is autohotkey -.-
|
|
|
09/30/2014, 18:44
|
#4
|
elite*gold: 15
Join Date: Aug 2012
Posts: 3,041
Received Thanks: 6,397
|
Quote:
Originally Posted by ankur850
SpeedAPI is nor autoIT nor it is autohotkey -.- 
|
I'm pretty sure I'm aware of that pal. I'm talking about the code:
Code:
http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards?et=$mpsp&eid=$eventid[0]<=$timeframe&rf=$time&dn=$name&shard=$server
Some languages have limitations, so you can never be sure. I need an example code(not with variable names but variables themselves) to check it.
|
|
|
09/30/2014, 20:00
|
#5
|
elite*gold: 0
Join Date: Apr 2013
Posts: 368
Received Thanks: 53
|
Quote:
Originally Posted by berkay2578
I'm pretty sure I'm aware of that pal. I'm talking about the code:
Code:
http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards?et=$mpsp&eid=$eventid[0]<=$timeframe&rf=$time&dn=$name&shard=$server
Some languages have limitations, so you can never be sure. I need an example code(not with variable names but variables themselves) to check it.
|
Its php. Thanks.
More info about the arguments can be found at  if the explanations below in my code are confusing.
PHP Code:
<?php //leaderboard timeframe(lt) 1=overall 2=daily 3=weekly 4=monthly //leaderboard request filter (rf) 0-6 for daily (days past since today), 1-52 for weekly (week of year), 1-12 for monthly (month of year) //mpsp 1=mp 2=sp //name = driver name //server = driver server //eventid = id number of event assigned by EA
$mpsp=1; //multiplayer $eventid=3; //Bristol and Diamond (other eventids can be found at the end of the url of track leaderboards on nfstimes $timeframe=4; //monthly leaderboard $time=6; //june of this year $name="RIDEMYBICYCLE"; $server="APEX";
if ($mpsp == 1) $timetable = "timemp"; elseif ($mpsp == 2) $timetable = "timesp"; else echo "Improper time frame. Please refer to code for correct implementation.";
// The POST URL and parameters $request = "http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards?et=$mpsp&eid=$eventid<=$timeframe&rf=$time&dn=$name&shard=$server"; echo $request . "<br>"; // Get the curl session object $session = curl_init($request);
// Set the POST options. curl_setopt ($session, CURLOPT_POST, true); curl_setopt ($session, CURLOPT_POSTFIELDS, $request); curl_setopt($session, CURLOPT_HEADER, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Do the POST and then close the session $response = curl_exec($session); curl_close($session);
// Get HTTP Status code from the response $status_code = array(); preg_match('/\d\d\d/', $response, $status_code);
// Check for errors switch( $status_code[0] ) { case 200: // Success break; case 409: die('Could be a number of EA errors. Please try again later.'); break; default: die('Your call returned an unexpected HTTP status of:' . $status_code[0]); }
// Get the XML from the response, bypassing the header if (!($xml = strstr($response, '<?xml'))) { $xml = null; }
// Output the XML
$worldLeaderboard = simplexml_load_string($xml);
echo "<br><br>"; print_r($worldLeaderboard); echo "<br><br>"; foreach ($worldLeaderboard->worldLeaderboard as $world) { echo $world['personaName']; echo $world['eventDuration']; } ?>
|
|
|
09/30/2014, 20:49
|
#6
|
elite*gold: 15
Join Date: Aug 2012
Posts: 3,041
Received Thanks: 6,397
|
So, I did this:
Code:
<?php
/*
et : event type, pvp1, pve2
eid : event id
lt : ldr type, all1, day2, week3, month4
dn : driver names - seperator comma
--opt:
rf : filter {
on days: (present)0-6(past)
on weeks: 1-52
on months: 1-12
}
shard: Apex,Chicane
*/
$eType=2;
$eId=45;
$lType=1;
$rFilter=6;
$dNames="berkay2578";
$shard="Apex";
$curl = curl_init();
$cOptions = array(
CURLOPT_URL => "http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards",
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "output=json&eid=".$eId."&et=".$eType."<=".$lType."&dn=".$dNames."&shard=".$shard
);
curl_setopt_array($curl, $cOptions);
$answer = curl_exec($curl);
curl_close($curl);
print_r($answer);
?>
I always get {"worldLeaderboards": []}(empty array) no matter what. Didn't really have the time to learn the API, am I missing something here?
|
|
|
09/30/2014, 22:43
|
#7
|
elite*gold: 0
Join Date: Apr 2013
Posts: 368
Received Thanks: 53
|
Quote:
Originally Posted by berkay2578
So, I did this:
Code:
<?php
/*
et : event type, pvp1, pve2
eid : event id
lt : ldr type, all1, day2, week3, month4
dn : driver names - seperator comma
--opt:
rf : filter {
on days: (present)0-6(past)
on weeks: 1-52
on months: 1-12
}
shard: Apex,Chicane
*/
$eType=2;
$eId=45;
$lType=1;
$rFilter=6;
$dNames="berkay2578";
$shard="Apex";
$curl = curl_init();
$cOptions = array(
CURLOPT_URL => "http://world.needforspeed.com/SpeedAPI/ws/game/nfsw/leaderboards",
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "output=json&eid=".$eId."&et=".$eType."<=".$lType."&dn=".$dNames."&shard=".$shard
);
curl_setopt_array($curl, $cOptions);
$answer = curl_exec($curl);
curl_close($curl);
print_r($answer);
?>
I always get {"worldLeaderboards": []}(empty array) no matter what. Didn't really have the time to learn the API, am I missing something here?
|
I don't think you've run a time on Welcome to Palmont (track id 45) on that account. At least I don't see it on nfstimes (i just updated the account on nfstimes). If you have run that track before then I'm guessing it was a long time ago and I'm assuming nfstimes also has the limit that it can only get data from within the last like 2-3 months from the world servers =/. I also get an empty array when querying a record from more than that time frame and if you are getting the same then I'm pretty sure that's whats happening.
Guess worst case scenario I can figure out how to use regex and a scraper of some sort... kind of a pain though.
Also another question. JSON or XML? I couldn't decide which was better so I just went with the default but if JSON is much better I might as well switch now.
Thanks.
|
|
|
10/01/2014, 06:21
|
#8
|
elite*gold: 15
Join Date: Aug 2012
Posts: 3,041
Received Thanks: 6,397
|
well, i did do that track long time ago, everyone did tbh. i guess nfstimes has its own database and when you click update it compares the post return array of SpeedAPI with their own and then add not existing times to their database.
No luck, bad developers will always be bad.
well XML result starts with 'list' which is a function in php. I just like JSON better, json reading is more simple for me.
|
|
|
10/01/2014, 07:29
|
#9
|
elite*gold: 0
Join Date: Apr 2013
Posts: 368
Received Thanks: 53
|
haha alright thanks for your help. time for me to learn regex!
|
|
|
All times are GMT +1. The time now is 00:38.
|
|