Jump to content

PHP client for XML API?


virtualdevl

Recommended Posts

Build and POST XML

Hey guys, I am writing a small class to build and POST xml. I have a few XML requests that I have to build, i.e.:

 

1) getAuthKey

2) getUserInfo

3) getUserItems

 

Now question is this, do I just write functions with the XML echoed out and then populate the values of the XML nodes from params passed in? Or should I build the XML depending on the request with a generic build XML function? This is for a client and since I haven't worked much with XML I would like to know what the industry standard is as I want it to be as professional as possible. Thanks, any input is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/124328-php-client-for-xml-api/
Share on other sites

Mchl , thanks for the response, I am thinking of using simple xml or something, but what I need to know is if I should do as follows:

 

function getAuthCode($param_1 = null, $param_2 = null) {
  $this->xml = "<rootNode>\n";
  $this->xml .= "\t<request>getAuthCode</request>\n";
  $this->xml .= "\t<child1>{$param_1}</child1>\n";
  $this->xml .= "\t<child2>{$param_1}</child2>\n";
  $this->xml .= "\t<child3>{$param_1}</child3>\n";
  $this->xml .= "</rootNode>";
} 

 

 

and so forth for each request or should I not have the XML static and build it based on the request? I have to write an API client that POSTs this XML via HTTP.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.