cURL and IP Addresses

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ben91082
Forum Newbie
Posts: 1
Joined: Tue Apr 14, 2009 9:52 am

cURL and IP Addresses

Post by ben91082 »

Hello,

I am having trouble posting form data to a remote script using cURL where the script is located via an IP address. This is what I'm trying to do which is currently not working:

Code: Select all

 
$url = "http://xxx.xxx.xx.xxx:xxx/scripts/myscript.py";
$args = "username=".urlencode($user['username']);
 
                         $ch = curl_init();
 
                         curl_setopt($ch, CURLOPT_URL,$url);
                         curl_setopt($ch, CURLOPT_POST, 1);
                         curl_setopt($ch, CURLOPT_POSTFIELDS,$args);
                         $result= curl_exec ($ch);
                         curl_close ($ch);
However if I try a similar thing with an actual domain name, i.e same code as above but change $url to http://www.mydomain.com/scripts/myscript.py it works fine. Any ideas why this might not be working?

Thanks.
Last edited by Benjamin on Wed Apr 29, 2009 12:00 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: cURL and IP Addresses

Post by Christopher »

Can you access http://xxx.xxx.xx.xxx:xxx/scripts/myscript.py directly? I notice you have a port number in there. Is it 80?
(#10850)
Post Reply