PHP Classes

CallAPI result parameter format

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  CallAPI result parameter format  >  (Un) Subscribe thread alerts  
Subject:CallAPI result parameter format
Summary:Looking for recommendation for handling for CallAPI Result
Messages:6
Author:IT admin
Date:2015-03-25 23:25:14
 

  1. CallAPI result parameter format   Reply   Report abuse  
Picture of IT admin IT admin - 2015-03-25 23:25:14
I am using your class to access various providers with different versions of OAuth and different data being returned.

Sometimes the result is json object, other times simplexml object.

I would like to always receive these results as a generic string. Is there a way to do this?

If not, is there a way to get at that response header to tell me what the format is - so I can use appropriate code to convert it to string?

  2. Re: CallAPI result parameter format   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-25 23:37:52 - In reply to message 1 from IT admin
Try setting the ResponseContentType parameter to text/plain .

  3. Re: CallAPI result parameter format   Reply   Report abuse  
Picture of IT admin IT admin - 2015-03-26 01:49:49 - In reply to message 2 from Manuel Lemos
Manuel, thank you for the quick response.

I had read about that option, and it says an array will be returned. Since you are recommending it, I gave it a try. Looking at the results, it is definitely an array and no longer a JSON or XML object.

In the array, the results are oddly in the key vs value field of the array.

Unfortunately the data is cut off and spaces appear as underscores. I may really have underscores in data returned - and I do need it all.

Any other ideas would be appreciated!

  4. Re: CallAPI result parameter format   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-26 02:06:38 - In reply to message 3 from IT admin
Sorry, text/plain is interpreted as JSON because many APIs return JSON with text/plain.

Use application/octet-stream which for binary data.

  5. Re: CallAPI result parameter format   Reply   Report abuse  
Picture of IT admin IT admin - 2015-03-26 15:24:54 - In reply to message 4 from Manuel Lemos
Ok Manuel, that did the trick.

I am now receiving the raw data returned by queries. It goes into string just fine - just like the previous OAuth library did. This is helpful as all my downstream logging and logic was expecting and acting upon a string value. Saved me a lot of refactoring work!

.... Enjoying your class, thanks for writing and sharing it.

Regards

Lynn

  6. Re: CallAPI result parameter format   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-26 18:01:04 - In reply to message 5 from IT admin
Great, I am glad it worked.