These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Did Phoebe break/change the API XML, or did I break my PHP ?

First post
Author
lee james pearson
Monte Inc
#1 - 2014-11-07 12:39:19 UTC
Hi All,

I've got a simple bit of php that grabs my corp wallet transactions and stores it all in a database.
Has been working fine for about a year - until now.

Instead of getting a stack of new rows in my table, PHP is instead returning:


( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 13: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xC8 0x6C 0x3E 0x32 in C:\EVEThings\wamp\www\importxml.php on line 15

and
( ! ) Warning: SimpleXMLElement::__construct(): in C:\EVEThings\wamp\www\importxml.php on line 15

and
( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 14: parser error : Extra content at the end of the document in C:\EVEThings\wamp\www\importxml.php on line 15



Here is where its all going wrong:


->  ?php... mysql_connect...mysql_select_db... etc

12  echo "This is line 12";
13  $data = file_get_contents("https://api.eveonline.com/corp/WalletTransactions.xml.aspx?keyID=1234&vCode=numbersandletters&characterID=5678&rowCount=5");
14  echo "This is line 14";
15  $xml = new SimpleXMLElement($data);
16  echo "This is line 16";
17   if ($xml === false)
18      {    die('Error parsing XML');  }
19 
20  echo "This is line 20";
21 
22  foreach ($xml -> result -> rowset-> row as $row)
23      {
24          $transactionDateTime = $row['transactionDateTime'];
->...do the things to insert everything to the appropriate table..


Now the API is returning XML that looks fine if I copy out the appropriate line and run it through my browser.
My little database is otherwise running fine (but its all failing well before it tries to write anything to it anyhow - forgive my primitive attempts to troubleshoot this; the last thing that prints before we get orange and red PHP errors is "This is line 14")

- So everything is pretty much pointing to SimpleXMLElement being unhappy with what the API is sending back as XML

... Did Phoebe change something that I missed in the release notes ? Can someone assist with getting me on the right track to fixing it from my end (a few articles on stackoverflow I found, yet didnt fully understand, relating to parsing problematic XML that otherwise causes the exact error I'm getting)

thanks for your time, and any help
CCP FoxFour
C C P
C C P Alliance
#2 - 2014-11-07 13:05:50 UTC
I don't think we made any changes to the corp/WalletTransactions stuff... would be interested to know if anyone else is running into this.

@CCP_FoxFour // Technical Designer // Team Tech Co

Third-party developer? Check out the official developers site for dev blogs, resources, and more.

Yongtau Naskingar
Yongtau Naskingar Corporation
#3 - 2014-11-07 13:49:07 UTC
Did you try an XML validator? Are there any non-ascii characters in the XML?
lee james pearson
Monte Inc
#4 - 2014-11-07 14:43:30 UTC
Quote:
Did you try an XML validator?


@Yongatu -- I hadn't - but since have; Shows as 'No errors found' with just a copy paste of the returned xml from the webbrowser.

Also, I have just tested a little further by pointing Excel at the same API URL - correctly structured data, seemingly free of any unusual characters, populates excel just fine also.

So, it really seems like just my PHP isn't working - I cant think of any possible changes to my machine +the actual php file definitely hasn't changed.. Most recent entries in my db are dated 28-10-14, so it was all working two weeks ago.

Is there an alternate/better method for achieving this ? (I struggled for a long while to get this working originally, mostly by cobbling together snippets of other peoples examples and lots of trial and error. i.e my own ability to troubleshoot limited by a rather huge lack of knowledge Sad )

API -> DB via php - the short, short version of how it used to work:
$data = file_get_contents("Https://api.eveonline.com/...etc
$xml = new SimpleXMLElement($data);
foreach ($xml -> result -> rowset-> row as $row)
  {
    (split up the returned rows into individual useful bits)
    (build $insertquery)
    $insert = mysql_query ($insertquery, $link)
  }


Should I (or could I) be using something other than "file_get_contents" and "new simpleXMLelement" ? - are there equivalent/alternate functions I can test with ?
Xinryu
NEXUS Financial
#5 - 2014-11-07 14:48:05 UTC  |  Edited by: Xinryu
For fun, try

$data = utf8_encode(file_get_contents("https://api.eveonline.com/corp/WalletTransactions.xml.aspx?keyID=1234&vCode=numbersandletters&characterID=5678&rowCount=5"));


Hopefully nothing weird happens
lee james pearson
Monte Inc
#6 - 2014-11-07 15:06:42 UTC
Thanks Xinryu, can confirm both "fun" and "weird" occurred - New and different errors were had:

Adding utf8_encode resulted in these 5 errors:


( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 14: parser error : Extra content at the end of the document in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Warning: SimpleXMLElement::__construct(): </eveapi> in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Warning: SimpleXMLElement::__construct(): ^ in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Exception: String could not be parsed as XML in C:\EVEThings\wamp\www\importxml.php on line 15



Weird bit is that you appear to have solved the first error I was getting in my initial post; yet it is all still failing with "extra content at the end of the document", and also with some (more detailed apparently random characters in the 2nd and 3rd !warnings
Xinryu
NEXUS Financial
#7 - 2014-11-07 15:15:22 UTC
lee james pearson wrote:
Thanks Xinryu, can confirm both "fun" and "weird" occurred - New and different errors were had:

Adding utf8_encode resulted in these 5 errors:


( ! ) Warning: SimpleXMLElement::__construct(): Entity: line 14: parser error : Extra content at the end of the document in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Warning: SimpleXMLElement::__construct(): </eveapi> in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Warning: SimpleXMLElement::__construct(): ^ in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\EVEThings\wamp\www\importxml.php on line 15
( ! ) Exception: String could not be parsed as XML in C:\EVEThings\wamp\www\importxml.php on line 15



Weird bit is that you appear to have solved the first error I was getting in my initial post; yet it is all still failing with "extra content at the end of the document", and also with some (more detailed apparently random characters in the 2nd and 3rd !warnings

Yeah, that's what tends to happen when you encode in one format and decode in another. What version of PHP are you running?

Could try doing a var_dump($data) to see what that variable's holding (and potentially why the encoding's off)
lee james pearson
Monte Inc
#8 - 2014-11-07 15:24:54 UTC  |  Edited by: lee james pearson
I added
var_dump($data);
above line 15


New output is: (umm, needed to replace all <'s and >'s with { and } - forum got angry about me trying to paste html in... )

string '{?xml version='1.0' encoding='UTF-8'?}

{eveapi version="2"}

  {currentTime}2014-11-07 15:18:39{/currentTime}

  {result}

    {rowset name="transactions" key="transactionID" columns="transactionDateTime,transactionID,quantity,typeName,typeID,price,clientID,clientName,characterID,characterName,stationID,stationName,transactionType,transactionFor,journalTransactionID,clientTypeID"}

      {row transactionDateTime="2014-11-07 15:03:37" transactionID="3667776459" quantity="2" typeName="Beta Reactor Control: S'... (length=2777)

--> and then into the warnings

__________
And here's the pertinent's for PHP versions etc
Server Configuration
Apache Version :
2.4.4
PHP Version :
5.4.12
Loaded Extensions :
Corebcmathcalendarcom_dotnetctypedateeregfilterftphashiconvjsonmcryptSPLodbcpcreReflectionsessionstandardmysqlndtokenizerzipzliblibxmldomPDOopensslSimpleXMLwddxxmlxmlreaderxmlwriterapache2handlergdmbstringmysqlmysqliPharpdo_mysqlpdo_sqlitemhashxdebug
MySQL Version :
5.6.12
Xinryu
NEXUS Financial
#9 - 2014-11-07 16:12:36 UTC
lee james pearson wrote:
THINGS!

Well, I'm stumped. Just tested it on my own server, and everything's working fine.

More random things it could be: PHP memory limit, or something to do with your configuration of Apache 2.4

In any case, good luck with a solution!
Dragonaire
Here there be Dragons
#10 - 2014-11-07 16:39:46 UTC
So I've tested in Yapeal as well and no problems with the API but if you want to just make totally sure the XML is fine that you're getting here a link to the XSD I use to validate the received XML in Yapeal.
http://pastebin.com/AjgP6t2F
There's several online validators you can use just Google for them.

Finds camping stations from the inside much easier. Designer of Yapeal for the Eve API. Check out the Yapeal PHP API Library thread.

lee james pearson
Monte Inc
#11 - 2014-11-08 00:48:12 UTC
Thanks to everyone who took the time to look into this and help.

Now resolved - never did find out what actually caused it tho.

Plenty of random additional things were attempted - in the end I needed to completely blow away my entire WAMP instance, and install fresh (some minor crisis ensued re: almost misplacing my entire database of historical transaction data, but we got through that in the end...)

Absolute best guess; a windows update over the last fortnight somehow affected something that php needed, and it all broke at that point.

If google leads anyone else here experiencing the same thing -> backup your entire wamp folder, run the wamp uninstaller, delete the wamp folder that remains, download the newest wamp installer, and start over What?

Thanks again to everyone who helped!
Louis Vitton
Viziam
Amarr Empire
#12 - 2014-11-08 04:18:26 UTC
I am not a fan of wamp, just my preference though but if your production system is a Linux based one vagrant might be better.
https://www.vagrantup.com/
https://docs.vagrantup.com/v2/getting-started/
Dragonaire
Here there be Dragons
#13 - 2014-11-08 09:35:56 UTC
If you are running your app on Windows I'd use BitNami I've had much better luck with it 'just working' for me and continuing to compared to all the other Wamps.

Finds camping stations from the inside much easier. Designer of Yapeal for the Eve API. Check out the Yapeal PHP API Library thread.