Can you identify this API type?

Hey everyone, I’m working on a project where I need to send data to an API. I’ve got a simple form set up in Zend Framework 2, and it’s validating fine. But now I’m stuck on how to actually send the data to the API.

The API docs say to use “HTTP POST”, but I’m not sure what kind of API it is. When I make a GET request to the API URL with some parameters, I get an XML response. Here’s a snippet:

<response>
  <validresponse>YES</validresponse>
  <foo>21</foo>
  <bar>21</bar>
</response>

The response headers mention “Content-Type: text/xml” if that helps.

Any ideas on what type of API this might be? Is it SOAP, REST, or something else? I want to make sure I’m using the right approach to connect to it. Thanks for any help!

Based on the information you’ve provided, it sounds like you’re dealing with a simple XML-RPC API. This isn’t quite SOAP (which is more complex) or REST (which typically uses JSON these days), but rather a straightforward XML-based API.

To interact with this API, you’ll want to send an HTTP POST request with your data formatted as XML. The Content-Type header should be set to ‘application/xml’ or ‘text/xml’.

In Zend Framework 2, you can use the Zend\Http\Client to make the request. Here’s a rough example of how you might structure your code:

$client = new Zend\Http\Client($apiUrl);
$client->setMethod('POST');
$client->setHeaders(['Content-Type' => 'application/xml']);
$client->setRawBody($yourXmlData);
$response = $client->send();

You’ll need to construct your $yourXmlData string to match the format expected by the API. Parse the response as XML to extract the data you need.

Hope this helps point you in the right direction!

From what you’ve described, this appears to be a simple XML-based API, not quite SOAP or REST. The XML response and Content-Type header are key indicators. For sending data, you’ll need to construct an XML payload and send it via POST request.

In Zend Framework 2, you can use the HTTP client to accomplish this. Format your data as XML, set the Content-Type header to ‘application/xml’, and use the setRawBody method to add your XML payload. Then send the POST request to the API endpoint.

Remember to parse the XML response you receive back. The Zend\Xml\Parser component could be useful for this task. If you encounter any issues with the implementation, don’t hesitate to ask for more specific guidance.

looks like a basic xml api, not soap or rest. you’ll need to send xml data via post request. in zf2, use the http client, set content-type to ‘application/xml’, and add your xml payload with setRawBody. don’t forget to parse the xml response. good luck with your project!