doucheng4660 2015-11-01 21:50
浏览 50

如何获取google reCAPTCHA请求的用户IP地址? PHP Laravel 5

I have implemented the Google ReCaptcha where it verifies just the g-captcha-response from the $_POST and my secret. However, I don't know how to obtain or send the remote ip. I'm using Laravel 5 and I'm new to php in general. Any help would be much appreciated :)

  • 写回答

1条回答 默认 最新

  • dongpu2476 2015-11-02 00:51
    关注

    In Laravel,the Illuminate\Http\Request object has a method called ip(), so you can use that:

    Using Request Facade:

    $ipAddress = Request::ip();
    

    If you have an instance of request, i.e: $request then you may try this:

    $ipAddress = $request->ip();
    

    Also you may try this way:

    $ipAddress = app('request')->ip();
    

    Alternatively you may use $_SERVER['REMOTE_ADDR'] as already commented.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答