|
发表于 2023-6-7 19:52:19
|
显示全部楼层
贵州省贵阳市
给你个php的方法
/* 获取要发送的数据 */
$data = array(
'key1' => 'value1',
'key2' => 'value2'
);
/* 获取访问者的 IP 地址 */
$visitor_ip = $_SERVER['REMOTE_ADDR'];
/* 构造要发送的请求 */
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/api');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Forwarded-For: '.$visitor_ip));
$response = curl_exec($ch);
curl_close($ch); |
|