How to know the url that is calling the destination url using curl in the destination url?
Okay, I have this setup:
//in example1.com, I am setting cURL <br />
$c = curl_init(); <br />
curl_setopt($c, CURLOPT_URL, 'http://example2.com');
//now in example2.com <br />
Is it possible to get the URL "example1.com" which is calling this URL (example2.com)?
Using file_get_contents('php://input')
, I can get the input of example1.com but how can I get the URL whi开发者_StackOverflow中文版ch is the "example1.com" here in example2.com?
Not sure exactly what you're asking. If you want to know the URL you script is invoked as that is just a matter of something like
"http://" . $_SERVER["SERVER_NAME] . $_SERVER["REQUEST_URI"]
But if you are asking to know the URL of the client which requested you that is not possible. Because there is nothing to guarantee you were invoked by another URL. It could just be a user typing someting into a browser, a web crawler, a cron job, etc...
The only thing you can discover for sure about your client is the IP address and port
$_SERVER["REMOTE_ADDR"]
$_SERVER["REMOTE_PORT"]
If you client is a friently HTTP client you can get some other info such as
$_SERVER["HTTP_USER_AGENT"]
Now I'm not sure thats what you were asking, but its what I took from it.
精彩评论