Sample PHP Code
// Setup the payload here. The structure of the payload itself will obviously
// change depending on which method/dataset combination we call and what
// parameters that method/dataset combination requires.
// Note the inclusion of "apirequest=" at the start of the Payload string.
// This ensures that the POST data will be received by the API as a
// proper POST name/value pair.
// method such as file_get_contents, but traditionally, the cURL extension is the
// preferred way to send POST data to an endpoint service.
$XMLPayload = @"apirequest=<?xml version=\"1.0\" encoding=\"UTF-8\" ?><data>
<auth>
<loginname>your_api_username</loginname>
<key>your_api_key</key>
</auth>
<request>
<dataset>N</dataset>
<method>getGeoIDByCoord</method>
<count>false</count>
<returnType>xml</returnType>
<returnGeoType>wkt</returnGeoType>
<parameters>
<lat>40.713734</lat>
<lon>-74.011683</lon>
<submatch>N</submatch>
</parameters>
</request>
</data>";
// The API Endpoint
$endpoint = "https://api.maponics.com/interface/";
// Initialize the cURL object
$ch = curl_init($endpoint);
// Set some default options
curl_setopt($ch, CURLOPT_POST, TRUE); // Tells cURL we're doing a POST request
curl_setopt($ch, CURLOPT_POSTFIELDS, $XMLPayload); // Add the payload to the request
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Tell cURL we want to capture the response from the server
// Make the service call and assign the server's return to the $response variable
$response = curl_exec($ch);
// You can process the returned response here. For the purposes of this sample, we'll just
// dump the raw text to the screen
var_dump($response)