当 CURL 从我网站上的另一个脚本调用脚本时,识别脚本的最佳方法是什么?
设置自定义用户代理标头。
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'your_custom_user_agent');
在被调用的脚本中,您可以使用
if ($_SERVER['HTTP_USER_AGENT'] == 'your_custom_user_agent') {
// This is internal request!
}
当 CURL 从我网站上的另一个脚本调用脚本时,识别脚本的最佳方法是什么?
设置自定义用户代理标头。
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'your_custom_user_agent');
在被调用的脚本中,您可以使用
if ($_SERVER['HTTP_USER_AGENT'] == 'your_custom_user_agent') {
// This is internal request!
}