seoneo Posted June 3, 2010 Share Posted June 3, 2010 Hi all! There is an ASPX-page what I open in a browser and I get back an XML-code. I need to use it in PHP. My idea was I would "iclude" it with cURL. I can use with an ordinary page like google, but it fails when I use on a special port. How can I do it? Thanks the answers. This is the code, what I use: //http://www.domain.com:1234/path/file.aspx?p1=value $url = "http://www.domain.com/path/file.aspx"; $port = 1234; $postdata = "p1=value"; $cinit = curl_init(); curl_setopt($cinit, CURLOPT_URL, $url); curl_setopt ($cibit, CURLOPT_PORT , $port); curl_setopt ($cinit, CURLOPT_TIMEOUT , 10); curl_setopt($cinit, CURLOPT_RETURNTRANSFER, 1); curl_setopt($cinit, CURLOPT_POST, 1); curl_setopt($cinit, CURLOPT_POSTFIELDS, $postdata); $cexec = curl_exec($cinit); print_r(curl_getinfo($cinit)); echo "<hr>Error code:" .curl_errno($cinit); echo "<br>Error name:" . curl_error($cinit); curl_close($cinit); echo $cexec; Link to comment https://forums.phpfreaks.com/topic/203778-php-curl-manage-ports-how/ Share on other sites More sharing options...
TheBG Posted June 3, 2010 Share Posted June 3, 2010 The first thing I would do is change the handle in the CURLOPT_PORT line to $cinit instead of $cibit. Then I would turn on error checking while developing. Link to comment https://forums.phpfreaks.com/topic/203778-php-curl-manage-ports-how/#findComment-1067431 Share on other sites More sharing options...
seoneo Posted June 4, 2010 Author Share Posted June 4, 2010 Oh, thanks, I had corrected it earlier and I forgot to repair this mistake. A few minutes ago, I tried to use curl in console in my computer, and it runs successfully: curl http://www.domain.com:1234/path/file.aspx?p1=value After that my idea was I should use only CURLOPT_URL (with whole path) without CURLOPT_PORT, but it didn't work. Link to comment https://forums.phpfreaks.com/topic/203778-php-curl-manage-ports-how/#findComment-1067467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.