Pages: [1] :: one page |
|
Author |
Thread Statistics | Show CCP posts - 0 post(s) |
Niffetin
Gallente Omni Research
|
Posted - 2008.01.24 20:49:00 -
[1]
Anyone got some examples on how to, for example, get the very first job in this .xml file: Linkage
Been thinking whole day but I can only get it to return the API Version and currentTime, getting things past those is a complete mystery to me
--- Teeheee! |
MsRx7
Cutting Edge Incorporated RAZOR Alliance
|
Posted - 2008.01.25 04:31:00 -
[2]
$url = "http://api.eve-online.com/corp/MemberTracking.xml.aspx?userID=" . $userID . "&apiKey=" . $apikey . "&characterID=" . $characterID;
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, 1);
$xml = new SimpleXMLElement(curl_exec($ch)); curl_close($ch);
//Data parseing begins foreach ($xml->xpath('//error') as $error) { } if (!isset($error)) {
foreach ($xml->xpath('//row') as $row) { ### this is were you would parse out the data into sql or w/e the varibles are pulled down row by row into a array, for example to $row['beginProductionTime']
} } else { echo "Error: " . $error . "<br>"; } unset($error);
That is your basic PHP5 curl parser :)
you can parse that data into a array for local useage or into a database for later use.
|
Niffetin
Gallente Omni Research
|
Posted - 2008.01.25 05:04:00 -
[3]
Thanks, will try this out once API is back up
--- Teeheee! |
Johnathan Roark
Caldari Quantum Industries Interstellar Alcohol Conglomerate
|
Posted - 2008.01.25 07:30:00 -
[4]
This has a little bit more error handling and sends the parameters using POST instead of GET
$userid=;//userid goes here $apikey=;//apikey goes here $characterID=;//characterID goes here
$fail=0; $url = "http://api.eve-online.com/corp/MemberTracking.xml.aspx"; $data = array( 'userID' => $userid, 'apiKey' => $apikey, //Additional API parameters after this line 'characterID' => $characterID );
//Begins connecting to eve api
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $curl_error=curl_errno($ch); if($curl_error!=0) { $fail=1; echo $curl_error; } //if curl error if($fail!=1 || $curl_error!=0) { $xmlstr = ''; // empty to throw an exception //LOAD $ch from CURL into $xml as an SimpleXMLElement try {
$xml = new SimpleXMLElement(curl_exec($ch)); //$xml = new SimpleXMLElement($xmlstr); } catch (Exception $e) { // handle the error echo 'Not a valid xml string'; $fail=1; } //Close CURL connection curl_close($ch); if($fail!=1) { foreach ($xml->xpath('//error') as $error) { echo "Error: ".$error['code']."<br>\n"; echo $error."<br>\n"; $fail=1; } //foreach $xml xpath error as $error, api error handling if($fail!=1) { foreach ($xml->xpath('//row') as $row) { //Actual parsing goes here, values of $row are accessed as an associted array i.e. $row['itemID']; } //foreach $xml xpath row as $row } //if fail } //if fail or curl_error
Corporation Management Improvement |
Niffetin
Gallente Omni Research
|
Posted - 2008.03.03 06:37:00 -
[5]
Anyone got a parser example without using curl?
(The server I plan on using my stuff on doesn't have curl on it so I can't use that )
And zie ebil admin refuses to install it
--- Teeheee! mematar's Video Archive |
DeTox MinRohim
Madhatters Inc. Pure.
|
Posted - 2008.03.03 20:00:00 -
[6]
Edited by: DeTox MinRohim on 03/03/2008 20:00:40
Originally by: Niffetin Anyone got a parser example without using curl?
(The server I plan on using my stuff on doesn't have curl on it so I can't use that )
And zie ebil admin refuses to install it
Linkage ------ This sig space is Read-only ! omgalink - Online Skillsheet |
Niffetin
Gallente Omni Research
|
Posted - 2008.03.04 06:38:00 -
[7]
Originally by: DeTox MinRohim Edited by: DeTox MinRohim on 03/03/2008 20:00:40
Originally by: Niffetin Anyone got a parser example without using curl?
(The server I plan on using my stuff on doesn't have curl on it so I can't use that )
And zie ebil admin refuses to install it
Linkage
/me appreciates! --- Teeheee! mematar's Video Archive |
Nobues
Gallente Nomadic Wayfarer Syndicate
|
Posted - 2008.03.04 14:25:00 -
[8]
Edited by: Nobues on 04/03/2008 14:27:51 Edited by: Nobues on 04/03/2008 14:26:22 this might be a little easier for ya
this is a basic function for a set of tools I'm programing
userInfo is basic array with your apiKey, userID and anything else you need to pass
apiURLS
just replace that with the url need like (/char/SkillInTraining.xml.aspx)
http://pastebin.com/f7a11e4e7
Webhosting, teamspeak and Killboard for you, your corp, and your Alliance Click me for more info |
General Lysander
The Agoge
|
Posted - 2008.04.08 00:29:00 -
[9]
Anyone have a simple PHP script to pull your Corp's member list and output it in an HTML table?
|
DeTox MinRohim
|
Posted - 2008.04.08 10:19:00 -
[10]
Originally by: General Lysander Anyone have a simple PHP script to pull your Corp's member list and output it in an HTML table?
Linkage
------ This sig space is Read-only ! omgalink - Online Skillsheet |
|
General Lysander
The Agoge
|
Posted - 2008.04.08 18:16:00 -
[11]
Detox, I get a 500 server error running your script ugg.. any thoughts? All I changed was the relevant API portion
|
DeTox MinRohim
|
Posted - 2008.04.09 07:32:00 -
[12]
Originally by: General Lysander Edited by: General Lysander on 08/04/2008 18:38:19 Edited by: General Lysander on 08/04/2008 18:37:20 Edited by: General Lysander on 08/04/2008 18:31:07 Detox, I get a 500 server error running your script ugg.. any thoughts? All I changed was the relevant API portion
--
Actually I resolved this by changing directory permissions back disabling writables..
But... now when I run it I get this:
$eve_userid, ✀甀猀攀爀欀攀礀✀ 㴀㸀 ␀攀瘀攀开愀瀀椀欀攀礀Ⰰ
Stuff as output... argh and it isnt writing a members.txt
Oh?... oookay... will have a look. (but what is this chinese stuff??) Note that this was built fast some times ago on a local comp so didn't bother with file permissions, etc I admit. Will check it soon.
------ This sig space is Read-only ! omgalink - Online Skillsheet |
DeTox MinRohim
|
Posted - 2008.04.09 09:02:00 -
[13]
Added a temp folder to the thing (make sure you get all the files btw and chmod the temp folder, the members.txt will be saved in it).
Didn't get any problem so not sure what exactly was your issue.
------ This sig space is Read-only ! omgalink - Online Skillsheet |
Revanom
Gallente Mentis Fidelis R-I-P
|
Posted - 2008.04.09 20:16:00 -
[14]
Well the chinese is from firefox so maybe there is a language setting problem i am not chinese but in IE this is what dumps out only changes were adding the api info, and making a temp folder br br $eve_userid, userkey => $eve_apikey, charid => $eve_charid, charname => $eve_charname $xml = LoadData $config, members $xml = $xml[ eveapi ][ result ] $rows = $xml[ rowset ][ row ] $count = count $rows / 2 $members = array for $x = 0 $x < $count $x { $members[] = $rows[ $x attr; } foreach($members as $res) { $sortAarr[] = strtolower($res['name']); } array_multisort($sortAarr, SORT_ASC, $members); ?> Name Title Member since 60*60) { $header .= "Host: api.eve-online.com\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n"; $header .= "Connection: close\r\n\r\n"; $fp = fsockopen ('api.eve-online.com', 80, $errno, $errstr, 30); if (!$fp) { echo 'meh! Eve server is such a n00b! '.$errstr; exit; } fputs ($fp, $target . $header . $req); $res = ''; $done = false; while (!feof($fp)) { $res .= fgets ($fp, 1024); } fclose($fp); if ($handle = fopen($filename, 'a')) { if (fwrite($handle, $res) === FALSE) { echo "Cant open file ($filename)"; exit; } fclose($handle); } } else { if (!$handle = fopen($filename, 'r')) { echo "Cant open file ($filename)"; exit; } while (!feof($handle)) { $res .= fgets ($handle, 1024); } fclose($handle); } $data = array(); $start = ''; $end = ''; $null = eregi("$start(.*)$end", $res, $data); include_once 'xml.php'; $xml = XML_parsecontent($data[0]); return $xml; } ?> CEO - Mentis Fidelis We are always recruiting! Check our recruiting post. |
DeTox MinRohim
Madhatters Inc. Pure.
|
Posted - 2008.04.10 08:46:00 -
[15]
Mm do you have a link? Cause this is not helping much unfortunatly. (And do you have a ' in the name you put in the eve_charname value?
This can be related to a few things like how you saved the files from sourceforge or else.
Here are the files in a package to unzip: Linkage
The corpmembers2.php file is the same as the original except that the html is rendered by php, not cut through inside the file. Thought it might be the other problem.
Unzip, change the values (CHARNAME is optional in this case), upload all, chmod 777 the temp. Enjoy!
------ This sig space is Read-only ! omgalink - Online Skillsheet |
General Lysander
|
Posted - 2008.04.10 10:29:00 -
[16]
It works!
Quick question, does the script delete the members.txt file before grabbing new data? If not what code would be best to plug in to do that? I know I am a pain, sorry.
|
DeTox MinRohim
Madhatters Inc. Pure.
|
Posted - 2008.04.10 12:47:00 -
[17]
Originally by: General Lysander It works!
Quick question, does the script delete the members.txt file before grabbing new data? If not what code would be best to plug in to do that? I know I am a pain, sorry.
The file is cached for 1 hour in the script.
if (!file_exists($filename) || (time()-filemtime($filename)) > 60*60) {
If the file doesn't exist, it creates it... otherwise, it rewrites the content if the file is older than 1 hour (API restriction). ------ This sig space is Read-only ! omgalink - Online Skillsheet |
|
|
|
Pages: [1] :: one page |
First page | Previous page | Next page | Last page |