cURL ip地址 [英] cURL ip address

查看:96
本文介绍了cURL ip地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要发送一个curl请求与用户的ip地址而不是服务器。我试过这个没有运气:

I need to send a curl request with the user's ip address not the server one. I tried this with no luck:

curl_setopt( $ch, CURLOPT_INTERFACE, $ip );

有任何想法吗?

谢谢! / p>

Thanks!

推荐答案

确定,所以没有办法安全欺骗curl请求的ip地址,但我发现一个非安全的方式,它取决于接收请求的服务器脚本,但它为我欺骗我请求的API:

Ok, so there's no way to safely spoof the ip address of a curl request, but I found a non-safe way, it depends on the server script receiving the request, but it worked for me to trick the API I was making the request to:

curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));

这不总是可以工作,但在这种情况下,它为我工作。

This won't always work, but in this case it worked for me.

感谢大家的帮助!

这篇关于cURL ip地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆