open All Channels
seplocked EVE Technology Lab
blankseplocked Grabbing Alliance ID From API
 
This thread is older than 90 days and has been locked due to inactivity.


 
Author Topic

Puppy UK
Amarr
The Dark Light
The Dark Light.
Posted - 2011.07.22 07:39:00 - [1]
 

Edited by: Puppy UK on 22/07/2011 07:42:47
Edited by: Puppy UK on 22/07/2011 07:42:24
Edited by: Puppy UK on 22/07/2011 07:40:37
No alliance ID show up, Im assuming it is something to do with the the parent child relations in the second xml pull.

Thanks in advance for the help.

p.s. I made the PHP as readable as possible for you guys, no one likes reading messy code.



<html>
<head>
<title>API Submit</title>
</head>
<body>
<?php
$apiuser=$_POST['apiuser'];
$apikey=$_POST['apikey'];
function get_url_contents($url)
{
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$userquery = "http://api.eveonline.com/account/Characters.xml.aspx?userID={$apiuser}&apiKey={$apikey}";
$userxmlfile = get_url_contents($userquery);
$userxml = new SimpleXMLElement($userxmlfile);
$userxmlrow = $userxml -> result -> rowset -> row;

foreach($userxmlrow as $userxmlrow)
{
$charname = $userxmlrow[name];
$charid = $userxmlrow[characterID];
$corpname = $userxmlrow[corporationName];
$corpid = $userxmlrow[corporationID];

$corpquery = "http://api.eveonline.com/corp/CorporationSheet.xml.aspx?userID={$userid}&apiKey={$apikey}&characterID={$charid}";
$corpxmlfile = get_url_contents($corpquery);
$corpxml = new SimpleXMLElement($corpxmlfile);
$corpxmlrow = $corpxml -> result -> allianceID;

if($charname == "Puppy UK")
{
echo ("Char Name : " . $charname . "<br />");
echo ("Alliance ID : " . $corpxmlrow[allianceID] . "<br />");
echo ("<br />");
}
}
?>
</body>
</html>

Desmont McCallock
Posted - 2011.07.22 08:11:00 - [2]
 

This is what you get when you use diff UserID variable names in your calls.
$userquery = "http://api.eveonline.com/account/Characters.xml.aspx?userID={$apiuser}&apiKey={$apikey}";
$corpquery = "http://api.eveonline.com/corp/CorporationSheet.xml.aspx?userID={$userid}&apiKey={$apikey}&characterID={$charid}";

Puppy UK
Amarr
The Dark Light
The Dark Light.
Posted - 2011.07.22 08:18:00 - [3]
 

yes yes, I am ******ed.
I checked everything 20 times over.
Thanks a lot for the spot.
Its still not working, but i can get back to working on the relationships now.
Thanks a lot.

Lutz Major
Posted - 2011.07.22 08:19:00 - [4]
 

I'm No PHP guy, but isn't the $corpxmlrow already the allianceID? When you print it you aka again for the field allianceID from that $corpxmlrow ?!?

Desmont McCallock
Posted - 2011.07.22 08:56:00 - [5]
 

That's it Lutz and to make the code more readable replace:
$corpxmlrow = $corpxml -> result -> allianceID;
with
$allianceID = $corpxml -> result -> allianceID;
and
echo ("Alliance ID : " . $corpxmlrow[allianceID] . "<br />");
with
echo ("Alliance ID : " . $allianceID . "<br />");

Still though it pops up some errors to me.


Desmont McCallock
Posted - 2011.07.22 09:15:00 - [6]
 

Although I too am NO PHP guy, consulting my books I found where the problem is.

Puppy UK, we both fail on Basic SimpleXML syntax:

$charname = $userxmlinfo['name'];
$charid = $userxmlinfo['characterID'];
$corpname = $userxmlinfo['corporationName'];
$corpid = $userxmlinfo['corporationID'];

Puppy UK
Amarr
The Dark Light
The Dark Light.
Posted - 2011.07.22 13:31:00 - [7]
 

Edited by: Puppy UK on 22/07/2011 13:33:01
Edited by: Puppy UK on 22/07/2011 13:32:41
For whoever is interested here is the code when I ran out of energy at the end of the day.

This is designed to store our members api details, and run against an hourly job to control the access levels on our forums.

When a member joins the alliance he will input his API information, and this code wil automatically set his forum permissions strait away, which will in turn allow him access to the comms server.

Part 2 of this project will be an hourly job to scan all the stored api's and maintain correct access on all members. This will be easy using this code as a base.


<html>
<head>
<title>API Results</title>
</head>
<body>
<?php
//Include the database connection
include("XXXXXXXXXX/dbconnect.php");
//Static variables
$charcount = 0;
$tdlcorpid = XXXXXXXXXX;
$tdlwcorpid = XXXXXXXXXX;
//POST Variables
$apiuser=$_POST['apiuser'];
$apikey=$_POST['apikey'];
/*
echo("GLOBAL INFORMATION" . "<br />");
echo("Api User : " . $apiuser . "<br />");
echo("Api Key : " . $apikey . "<br />");
echo("TDL Corp ID : " . $tdlcorpid . "<br />");
echo("Waffle Corp ID : " . $tdlwcorpid . "<br /><br />");
*/
//Function for collecting API while Bypassing the serveer side restrictions
function get_url_contents($url)
{
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
//Building Query to Collect Character and Corp information
$userquery = "http://api.eveonline.com/account/Characters.xml.aspx?userID={$apiuser}&apiKey={$apikey}"; $userxmlfile = get_url_contents($userquery);
//Collecting XML into an Array
$userxml = new SimpleXMLElement($userxmlfile); $userxmlrow = $userxml -> result -> rowset -> row;
//Foreach to work on each character contained within the API
foreach($userxmlrow as $userxmlrow)
{
//Character specific API information collection
$charname = $userxmlrow[name];
$charid = $userxmlrow[characterID];
$corpname = $userxmlrow[corporationName];
$corpid = $userxmlrow[corporationID];
//Building second query for collecting corp information for each character on the API
$corpquery = "http://api.eveonline.com/corp/CorporationSheet.xml.aspx?userID={$apiuser}&apiKey={$apikey}&characterID={$charid}";
$corpxmlfile = get_url_contents($corpquery); $corpxml = new SimpleXMLElement($corpxmlfile);
//Collecting alliance information for each character
$alliancename = $corpxml -> result -> allianceName;
$allianceid = $corpxml -> result -> allianceID;
//Query the forum to collect member information matching the API Character
$querygetcharid = "SELECT * FROM `tdlforummembers` WHERE `name` = '{$charname}'";
$result = mysql_query($querygetcharid) or die(mysql_error());
$row = mysql_fetch_array($result);
//Char count will be used for final client output update
$charcount = $charcount + 1;
//Collecting Forum information from the SQL database
$memberid = $row['member_id'];
$membergroupid = $row['member_group_id'];
$membername = $row['name'];

/*
TODO LIST
-----
Query to see if api data is already stored in tdlapi
Query to UPDATE tdlapi if data is already present
Query to INSTER api information into tdlapi if api data is not present
Query and logic for updating forum premissions based on corpid/allianceid/title for both the main and the training corp
Form Verification
Anti Injection on the inbound form
Error messages and exception catching
Build reusable code into functions for cronjob
*/
}
?>
</body>
</html>

Desmont McCallock
Posted - 2011.07.22 16:30:00 - [8]
 

You still have the wrong syntax for $charname,$charid,$corpname,$corpid in your code.
On another note, can you please edit your post as you are breaking the forum (at least on my 1280x1024 monitor).


 

This thread is older than 90 days and has been locked due to inactivity.


 


The new forums are live

Please adjust your bookmarks to https://forums.eveonline.com

These forums are archived and read-only