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.
 

Problem with the api ( evapi + doctype) and solution in php

Author
Inactive Seller
Hedion University
Amarr Empire
#1 - 2017-05-02 11:51:46 UTC
Today passing the Maintenance window, i begin to get the valid response finishing in < /eveap i> , but a whole doctype document passing the final of the data. I connect using a curl.

I resolve the rpoblem doing this before ths simplexml call:

$arr=explode("< /eveapi >",$data);
if (strlen($arr[0] < >'')){
$data=$arr[0]."< /eveapi >";
}
$apiInfo = new SimpleXMLElement($data);

i assume the curl response is $data, maybe you need to modify your call some times in your code (i must do five times ), i put some spaces to be able to post here.

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.

Zerzzes Markarian
McCloud and Markarian Trade and Logistics Corp.
#2 - 2017-05-02 15:13:11 UTC
I.m also having API problems since downtime.....
Inactive Seller
Hedion University
Amarr Empire
#3 - 2017-05-02 15:20:45 UTC
check the api result in plaintext . some as htmlentities($data) in PHP, you are getting the api and a whole web page too.

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.

Drakul Zephyrus
Garoun Investment Bank
Gallente Federation
#4 - 2017-05-02 15:33:33 UTC
They are parsing now .net output with the XML curl requests...

If you curl "https://api.eveonline.com/server/ServerStatus.xml.aspx" you see the normal XML output plus the html garbage...
Inactive Seller
Hedion University
Amarr Empire
#5 - 2017-05-02 15:37:04 UTC
Agree, i already put the solution in PHP to that problem

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.

MJ Maverick
Hybrid Industrial
#6 - 2017-05-02 16:40:13 UTC  |  Edited by: MJ Maverick
Also having this issue... CCP confirm?

Quote:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 31: parser error : Extra content at the end of the document in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: < /eveapi >< !DOCTYPE html > in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226
An error occured: API Date could not be read / parsed, original exception: String could not be parsed as XML [A106]
Inactive Seller
Hedion University
Amarr Empire
#7 - 2017-05-02 19:46:55 UTC
Maybe clean the string data before covert to xml. I dont use Pheal, but function for me.

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.

Cassie Helio
Push Industries
Push Interstellar Network
#8 - 2017-05-03 03:52:08 UTC  |  Edited by: Cassie Helio
MJ Maverick wrote:
Also having this issue... CCP confirm?

Quote:
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 31: parser error : Extra content at the end of the document in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: < /eveapi >< !DOCTYPE html > in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/sever/public_html/ts3api/pheal/Pheal.php on line 226
An error occured: API Date could not be read / parsed, original exception: String could not be parsed as XML [A106]


If you look at the raw response from file_get_contents() or cUrl you will see that after the end of the XML there is a .NET error saying User Agent is not set. CCP must have updated something today and their service is throwing that exception. Your code is throwing that error because after the end of the XML, which ends with /eveapi>, there is more content. The XML parser does not like that. I fixed it in my app by getting the the raw contents of the XML call result and cutting everything off after /eveapi>

NOTE: If you make the call by directly pasting the xml URL into a browser address bar you will NOT see the error because a browser sets the User Agent string but the SimpleXMLElement() does not.
Santinav
Back to Babylon
#9 - 2017-05-03 08:51:19 UTC  |  Edited by: Santinav
Simply set an UserAgent to your Curl-Request.

foobar = could be any String

curl_setopt($ch, CURLOPT_USERAGENT, 'foobar');

This will fix your calls. Big smile
Sansire Nerevar
Okela Mineral Exchange
#10 - 2017-05-03 11:01:38 UTC  |  Edited by: Sansire Nerevar
Santinav wrote:
Simply set an UserAgent to your Curl-Request.

foobar = could be any String


I dont like such quickfixes. CCP must fix this.

The raw response form file_get_contents() for my account balance is:

Quote:

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
webapp.utils.DDogManager.GetAgentData(String userAgent) +24
webapp.utils.DDogManager.GetAgentTags(String userAgent) +45
webapp.utils.DDogManager.StoreStat(HttpRequest request, Int32 statusCode, List`1 additionalTags) +448
BasePage.BasePage_Error(Object sender, EventArgs e) +677
System.Web.UI.TemplateControl.OnError(EventArgs e) +142
System.Web.UI.Page.HandleError(Exception e) +106
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +10415
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +361
System.Web.UI.Page.ProcessRequest() +76
System.Web.UI.Page.ProcessRequest(HttpContext context) +70
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +508
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +92

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1590.0



EDIT:

Its working now by the way.
Inactive Seller
Hedion University
Amarr Empire
#11 - 2017-06-08 00:39:52 UTC
Broke again today in the api of the specific character.

I must comment my old solution and put an user agent call passing each curl_init, and later use trim before convert to xml.

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.

Achanjati
Royal Amarr Science Institute
Royal Amarr Space Industries
#12 - 2017-06-08 09:37:17 UTC
Added the user agent to my skripts. So far, seams to work.
Was there any anouncement of this change I have missed? Was noch active watching for api chances the last weeks so I might have missed it.
Leila Larphson
Interstellar Exploration Center
#13 - 2017-06-08 10:21:24 UTC  |  Edited by: Leila Larphson
Have used CURLOPT_USERAGENT all the time, but having problems with certain api requests at the moment as well.
Already built in a trim of everything after < / eveapi > to get rid of the < DOCTYPE > rubbish at the end.
I use file_get_contents() for most calls and nothing (empty string) is returned. But if I paste the url in IE or Chrome it works fine, I get normal response data, for example:


< eveapi version="2" >
   < currentTime > 2017-06-08 09:55:45 < /currentTime >
   < result >
     < rowset name="jobs" key="jobID" columns="jobID,installerID,installerName,facilityID,solarSystemID,solarSystemName,stationID,activityID,blueprintID,blueprintTypeID,blueprintTypeName,blueprintLocationID,outputLocationID,runs,cost,teamID,licensedRuns,probability,productTypeID,productTypeName,status,timeInSeconds,startDate,endDate,pauseDate,completedDate,completedCharacterID,successfulRuns" / >
   < /result >
   < cachedUntil > 2017-06-08 10:09:45 < /cachedUntil >
< /eveapi >



EDIT: Never mind, works again.
Inactive Seller
Hedion University
Amarr Empire
#14 - 2017-06-08 14:19:58 UTC
Leila Larphson wrote:
Have used CURLOPT_USERAGENT all the time, but having problems with certain api requests at the moment as well.
Already built in a trim of everything after < / eveapi > to get rid of the < DOCTYPE > rubbish at the end.
I use file_get_contents() for most calls and nothing (empty string) is returned. But if I paste the url in IE or Chrome it works fine, I get normal response data, for example:


< eveapi version="2" >
   < currentTime > 2017-06-08 09:55:45 < /currentTime >
   < result >
     < rowset name="jobs" key="jobID" columns="jobID,installerID,installerName,facilityID,solarSystemID,solarSystemName,stationID,activityID,blueprintID,blueprintTypeID,blueprintTypeName,blueprintLocationID,outputLocationID,runs,cost,teamID,licensedRuns,probability,productTypeID,productTypeName,status,timeInSeconds,startDate,endDate,pauseDate,completedDate,completedCharacterID,successfulRuns" / >
   < /result >
   < cachedUntil > 2017-06-08 10:09:45 < /cachedUntil >
< /eveapi >



EDIT: Never mind, works again.


I had the same problems and result one of my calls have diff name of variant in the user agent. I change all the user agents to use the same variable, and answer as googlebot. Maybe need do a wrapper around the curl to modiify in only a place, but was a surprise yesterday.

All character bazaar done. Finally 39 pilot and 3 can be killed later. This account will be used only for forum interaction, fly safe.