Jump to content

Retrieving XML with cURL


brucegm

Recommended Posts

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? Any assistance would be much appreciated.

 

http://196.11.120.190:8080/mtnusa/client.jsp?command=<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>

 

The function I am using (from http://davidwalsh.name) is:

 

/* 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>');

Link to comment
Share on other sites

  • 6 months later...

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.