PHP的检测/获得POST请求发送URL(或服务器) [英] php detect/ get the sender url (or server) of post request
本文介绍了PHP的检测/获得POST请求发送URL(或服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设X.com会发送POST请求Y.com Ÿ怎么知道发件人为X?没有网址的查询字符串过程。
Suppose X.com will send a post request to Y.com How Y know that the sender is X? Without the url query string course.
$ _ SERVER http://php.net/的['HTTP_REFERER']手动/ EN / reserved.variables.server.php 似乎没有答案。该文件是自说,它不能真正被信任。
$_SERVER['HTTP_REFERER'] of http://php.net/manual/en/reserved.variables.server.php seems not the answer. The documentation it self says "it cannot really be trusted".
应该是用钥匙&放大器;密钥参数?
Should it use key & secret key parameter?
推荐答案
发送跨秘密的评估您的要求,比如它可以为您在脚本上X.com的关键
Send a secret value across with your request, such as a key which you can check for in your script on X.com
Y.com:
$secret = 'SECRET_KEY';
X.com:
X.com:
if(!empty(htmlentities($_POST['secret'])) {
if(htmlentities($_POST['secret']) == 'SECRET_KEY') {
//Request came from Y.com
}
}
这篇关于PHP的检测/获得POST请求发送URL(或服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文