Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当 CURL 从我网站上的另一个脚本调用脚本时,在脚本中识别的最佳方法是什么?
设置自定义 User-Agent 标头。
$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! }