卷曲IP地址 [英] cURL ip address
本文介绍了卷曲IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用用户的 IP 地址而不是服务器地址发送 curl 请求.我没有运气就试过这个:
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 );
有什么想法吗?
推荐答案
好的,所以没有办法安全地欺骗 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.
感谢大家的帮助!
这篇关于卷曲IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文