Retrieving XML with cURL
Posted: Thu Mar 10, 2011 7:07 am
Hi there
I am trying to use cURL to retrieve XML from a gateway. The code I am using works (ie. returns the HTTP response) for any URL that I use except the one that I need! The URL is below, and when using that I get a blank response every time. I've tested and can telnet to that IP address on that port from my server.
I'm not sure if it is because of the format/structure of the URL? Could it have something to do with the port of the gateway or the whay the parameters are being sent? Any assistance would be much appreciated. The URL I am accessing, and the code are both below:
URL
http://196.11.120.190:8080/mtnusa/clien ... nd=<usareq NODE="tHTTP" USERNAME="HTTP" PASSWORD="1234" TRANSFORM="SMPP"><command><submit_sm><a_number>278200703520709</a_number><b_number>27824411926</b_number><service_type/><message>Test</message><registered_delivery/></submit_sm></command></usareq>
CODE
The function I am using (from http://davidwalsh.name) is:
I am trying to use cURL to retrieve XML from a gateway. The code I am using works (ie. returns the HTTP response) for any URL that I use except the one that I need! The URL is below, and when using that I get a blank response every time. I've tested and can telnet to that IP address on that port from my server.
I'm not sure if it is because of the format/structure of the URL? Could it have something to do with the port of the gateway or the whay the parameters are being sent? Any assistance would be much appreciated. The URL I am accessing, and the code are both below:
URL
http://196.11.120.190:8080/mtnusa/clien ... nd=<usareq NODE="tHTTP" USERNAME="HTTP" PASSWORD="1234" TRANSFORM="SMPP"><command><submit_sm><a_number>278200703520709</a_number><b_number>27824411926</b_number><service_type/><message>Test</message><registered_delivery/></submit_sm></command></usareq>
CODE
The function I am using (from http://davidwalsh.name) is:
Code: Select all
/* gets the data from a URL */
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$returned_content = get_data('http://196.11.120.190:8080/mtnusa/client.jsp?command=<usareq NODE="HTTP" USERNAME="HTTP" PASSWORD="1234" TRANSFORM="SMPP"><command><submit_sm><a_number>278200703520709</a_number><b_number>27824411926</b_number><service_type/><message>Test</message><registered_delivery/></submit_sm></command></usareq>');