PHP Classes

Invalid Json / XML when the the response data is logn

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Invalid Json / XML when the the...  >  (Un) Subscribe thread alerts  
Subject:Invalid Json / XML when the the...
Summary:Invalid Json / XML when the the response data is logn
Messages:6
Author:Jinzhe Li
Date:2014-03-03 00:55:48
Update:2014-03-16 12:19:38
 

  1. Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Jinzhe Li Jinzhe Li - 2014-03-03 00:55:48
First all, I'd like to thank you for the brilliant job for this easy-to-use OAuth implementation!

Everything works as expected except that when I tried to get some relatively long response (say:length=25637), XML will give me some data with either special character (diamond with a question mark in the center) or incorrect XML close tag which make simple_xml_reader throw an error. I also tried JSON response however, the following error message is shown:
"Error: it was not returned a valid JSON definition of the API call values".

On the other hand, those relatively short response is ok and can be parsed successfully.

My first guess was there is some server side encoding issue, however, I checked their api previewer and had the same parameter and it showed the correct response (Both XML and JSON).

I wonder if you have any suggestion to solve this problem?

Thanks again! :)

  2. Re: Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Jinzhe Li Jinzhe Li - 2014-03-03 02:16:38 - In reply to message 1 from Jinzhe Li
The breakdown response size is between 15509 and 16331

Any response which is small than this threshold works fine whereas which is larger than this seems to have weird characters and incorrect closing tag for XML.

Any setting you recommend me to tune? Cheers

  3. Re: Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-03-03 03:03:44 - In reply to message 1 from Jinzhe Li
Can you provide a small code sample you are using so I can reproduce the problem?

  4. Re: Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Jinzhe Li Jinzhe Li - 2014-03-03 05:16:41 - In reply to message 3 from Manuel Lemos
Thank you for your reply !

I am using API provided by Xero (http://www.xero.com/au/)

I've made the sample code available here:

dropbox.com/s/ryy5ek28xt69uaj/sampl ...

on line 162 you can change the date range to get different size of response data.

You may need the following Xero acc to login:
username: jinzhedna@gmail.com
password: p9QiH7TC

Cheers! Your help is very much appreciated :)




  5. Re: Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Jinzhe Li Jinzhe Li - 2014-03-03 05:25:26 - In reply to message 3 from Manuel Lemos
The sample code simply does the following things as an example:
1. Fetch the bank report summary first including the uid for each bank account. (Line 106 - Line 150)
2. After successfully obtaining the uid for each bank account, request for detailed transaction during the specified time frame. (Line 154 - Line 208)

  6. Re: Invalid Json / XML when the the...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2014-03-16 12:19:38 - In reply to message 4 from Jinzhe Li
Sorry for the delay.

I am not able to reproduce the problem because your example is too complex.

Can you provide an simple example that can be reproduced with the demo company, hopefully just a single API call that shows the behavior?