Reputation: 177
How to know, who made POST
request to my server?
Other server makes POST
request to my servers API -> My server
looks up who made this request. ( hostname )
Upvotes: 1
Views: 966
Reputation: 177
Thanks everyone for answers.
Thanks to Nick I was able to get servers IP address. I went further and found this function -> gethostbyaddr()
This is what I initially wanted:
( taken from http://php.net/manual/en/function.gethostbyaddr.php )
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
Hope this helps someone, as I didn't knew about this function before.
Upvotes: 0
Reputation: 318
If someone is hitting your API, you can always get details using $_SERVER['HTTP_REFERER']
. You can also use $_SERVER['REMOTE_ADDR']. "-". $_SERVER['REMOTE_HOST']
to pin point and track with more efficiency.
Upvotes: 1
Reputation: 5929
There are multiple answers to this one.
As @Nick mentioned, there is the ip address that the request came from.
There is also the browser - this is also in the $_SERVER header.
If you want to know more, then you might need some sort of "password" to use your server - often called a "token", which uniquely identifies the requesting server - no token, no service. Then you will know.
Upvotes: 1
Reputation: 2512
You can use $_SERVER['REMOTE_ADDR']
for the server IP from which request is made.
Upvotes: 6