To which IP does an Http request from a PHP script resolves?

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
hombredecalle
Forum Newbie
Posts: 2
Joined: Sun Jul 09, 2006 2:33 am

To which IP does an Http request from a PHP script resolves?

Post by hombredecalle »

Hello,

Kinda simple question that I'm stuck with.

I have a PHP script that calls an external (3rd party - not mine) ASP service and stores the response in a simple string.

Here the code:

Code: Select all

$url = "http://www.someserver.com/service.aspx?p1=x&p2=y";
$xmlResponse = file_get_contents($url);
The problem
I need that the call for this "service.aspx" will originate from my server IP, NOT from my private user IP. This is because this service has IP restriction and is cofigured to work only if requested from my server IP.

At the moment - any invokation of "service.aspx" shows that the referral IP is my private IP.

How can I make a simple http request that will originate from my server IP, and not from the user's IP ?

Would be glad for any lead here... 8)
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

As far as I know, file_get_contents should originate from your servers IP. But take a look at the curl functions anyways. http://php.net/curl
hombredecalle
Forum Newbie
Posts: 2
Joined: Sun Jul 09, 2006 2:33 am

Post by hombredecalle »

Hi,

thanks for the answer.
I would have thought that too, but from the response I get, seems like it isn't the server IP.

Would u recommend using the Curl functions?
Post Reply