获取发送 cURL 请求的用户的 IP 地址 [英] Getting IP Address of a user who sent a cURL request

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

问题描述

我想获取使用 php 中的 cURL POST 方法向我的服务器发送请求的用户的 IP 地址?

I want to get The IP Address of user who sent a request to my server using cURL POST method in php ?

我正在开发 Flight API,我将使用 cURL POST 方法获取请求,我必须获取客户端的 IP 地址并验证他的 IP 地址是否可用.如果在我的数据库中可用,我将通过 JSON 向他发送响应.

I'm developing a Flight API, I'll get the Requests using cURL POST method, I've to get the IP address of the client and validate weather his IP address is available or not. If available in my DB i will sent him the response by JSON.

无论如何都可以在 php 中使用吗?

Is it possible anyway in php ?

推荐答案

可以从服务器变量中获取请求IP地址.

You can get the request IP address from server variable.

$_SERVER["REMOTE_ADDR"]

$_SERVER["REMOTE_ADDR"]

这篇关于获取发送 cURL 请求的用户的 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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