I've contacted some website administrators for their API, inreturn, they have asked for source IP to whitelist it so that only requests from that IP will be considered as legit (its ok even if its shared IP).

So, now the problem is how do i get ip of site. Being a PHP developer, I've tried gethostbyname() which gives random ip's & also $_SERVER['REMOTE_ADDR'] (called from other server) which always gives the single IP. I'm totally confused with this & also, I've very less time to give them my source IP.

I don't have paid hosting. I always use, free tiers of appfog (.aws.af.cm) & openshift (-name.rhcloud.com). It would be great if someone can tell me process for finding any of those IP address or show me a way to get static IP(which i could share with them) for free or anyother host. Also,they have given permission to use this api only for 10days. Thanks in advance.

So, now the problem is how do i get ip of site.

Do you mean the IP of the web server? That would need to be provided by the web server hosting/provider.


If you are using this code in your web page, you are collecting the source iP of your web page visitor, not the web server itself.

So, to clarify, which IP address are you trying to get, the web visitor or the web server?