$company_name, "company_num"=>$company_num, "company_bus_ind"=>$company_bus_ind, "address"=>$address, "skip"=>$skip, "max"=>$max, "searchType"=>$searchType, "sortBy"=>$sortBy, "sortDir"=>$sortDir, "htmlEnc"=>"1"); // Encode everything that will be sent to query string. $encoded = ''; foreach($testdata as $name => $value){ $encoded .= urlencode($name).'='.urlencode($value).'&'; } // chop off the last ampersand $encoded = substr($encoded, 0, strlen($encoded)-1); echo '

The query string we are going to send is:

'; echo "

". $encoded ."

"; $ch = curl_init(); $url = "https://services.cro.ie/cws/companies?" . $encoded; // base64_encode email_address:api_key, preceeded with "Basic ". // Use the exact email address you signed up with, values are case sensitive. $headers = array( "Authorization: Basic ".base64_encode("test@cro.ie:da093a04-c9d7-46d7-9c83-9c9f8630d5e0"), "Content-Type: application/xml", "charset: utf-8"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // curl_setopt($ch, CURLOPT_PROXY, 'http://ip of your proxy:8080'); // if you need to go through a proxy curl_setopt($ch, CURLOPT_FAILONERROR,1); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, 0); $response = curl_exec($ch); // Some values from the header if want to take a look... $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $headerOut = curl_getinfo($ch, CURLINFO_HEADER_OUT); echo $code.'

'.$headerOut.'

'; // Don't forget to close handle. curl_close($ch); // To view the data in its entirety: // print ("
");
// print_r($response);
// print ("
"); echo "

Results:

"; // To handle XML... $oXML = new SimpleXMLElement($response); // Please READ THE DOCUMENTATION on the list of fields avaiable: // ------->>>> https://services.cro.ie/datadict.aspx foreach($oXML->Company as $oDoc){ // Let's just show the name, first line of address, and the primary key , i.e. company num + comp business indicator: $primarykey = $oDoc->company_num.'/'.$oDoc->company_bus_ind; $company_name = $oDoc->company_name; $addr1 = $oDoc->company_addr_1; $addr2 = $oDoc->company_addr_2; print_r ($primarykey.'
'. $company_name.'
'.$addr1.' '.$addr2.'

' ); print_r ("===========================
"); } ?>