Page 1 of 1

question about using cURL with an ip address and port

Posted: Wed Oct 28, 2009 6:56 am
by energyguy
Hi,

Great forum. Thanks for all of the information and content. I'm new to php and have a question about loading a virtual XML file from an ip address and port. Here goes:

I have an energy monitoring device located at 98.251.95.89 on port 2533. Originally, I had it on port 80 to do some testing. I can access an xml feed of the energy data from the browser, using a direct DomDocument->load or from cURL when the port is set to 80 using the following url:

http://98.251.95.89/history/dailyhistory.xml?MTU=0

When I switched the port to 2533, I can still access the xml feed from the browser but I get the following error when I try using DomDocument->load or cURL. Here is the cURL code I'm using. Am I just missing something in how I need to pass the port? I've tried setting the CURLOPT_PORT but still get the same error. Thanks in advance for any help you can provide.

error: Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in .../beta/tweetawatt.php on line 66

Code: Select all

 
<?php
 
        $t5kUrl = "http://98.251.95.89:2533/history/dailyhistory.xml?MTU=0";
        $curl = curl_init();
        curl_setopt($curl,CURLOPT_URL,$t5kUrl);
//  curl_setopt($curl,CURLOPT_PORT,$tedPort);
        curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
        $xmlResult = curl_exec ($curl);
        curl_close ($curl);
 
        echo $xmlResult;
        $wattdoc->loadXML($xmlResult);
?>
 

When I try loading the url directly into the DOM using

Code: Select all

 
$xmlResult = $wattdoc->load($t5kUrl);
 
I get the following errors:

Warning: DOMDocument::load(http://98.251.95.89:2533/history/dailyhistory.xml?MTU=0) [domdocument.load]: failed to open stream: Connection refused in .../beta/tweetawatt.php on line 68

Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://98.251.95.89:2533/history/dailyhistory.xml?MTU=0" in .../beta/tweetawatt.php on line 68

I'm wondering if this could be an issue with my hosting. It's Godaddy economy linux.