定制 unvurn/http-user-agent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

unvurn/http-user-agent

最新稳定版本:v0.1.0

Composer 安装命令:

composer require unvurn/http-user-agent

包简介

README 文档

README

the simple parser for HTTP Request Header: "User-Agent"

Install

$ composer require unvurn/http-user-agent

Usage

    // Controller
    
    // api function that processes request from UnityPlayer
    public function get(Request $request) {
        $userAgent = $request->getUserAgent();
        if (!$userAgent->hasProduct("UnityPlayer")) {
            throw new BadRequestException("access allowed for UnityPlayer only");
        }

        // regular process
        
        return response()->json([
            // ...        
        ]);
    }
    // if you want to check "AppleWebKit" version:
    // ex) Windows 10/11
    //     Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
    public function get(Request $request) {
        $userAgent = $request->getUserAgent();
        if ($userAgent->product("AppleWebKit")?->version !== "537.36") {
            throw new BadRequestException("latest AppleWebKit version required");
        }

        // regular process
        
        return response()->json([
            // ...        
        ]);
    }

统计信息

  • 总下载量: 1.08k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-26