I want to read XML data from a URL in Magento.
I have three textboxes. One is for baseurl and others are for username and password respectively. when i enter these values i get url like "http://xyz.com/somefile.html?username=username&password=password"
I am using the curl method to get content of the url but nothing happens. Here is my code
$url='myurl';
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$tim开发者_开发百科eout);
$data = curl_exec($ch);
curl_close($ch);
I think there may be some problem with url because when i run this url on browser instead of showing xml contents it asks me to open or save the xml file.
Can anyone help me with this? I can not change the url so please suggest me some code that works with this type of url.
Get the cURL command line tool from its website and then run it like this:
curl -i "http://xyz.com/somefile.html?username=username&password=password"
That's an easy and reliable way to see what's going on at the HTTP level.
Alternatively, use Firefox with Firebug to find out what's going on.
精彩评论