effectra/tracker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

effectra/tracker

最新稳定版本:v1.0.0

Composer 安装命令:

composer require effectra/tracker

包简介

The Effectra Tracker package.

README 文档

README

Effectra Tracker is a PHP package that provides methods to extract information from the client's request, including IP address, browser details, operating system, device type, accepted languages, and referer URL. It also includes integration with IP tracking services to fetch additional attributes related to the provided IP address.

Installation

You can install the Effectra Tracker package via Composer:

composer require effectra/tracker

Usage

Tracker Class

Initialize Tracker

use Effectra\Tracker\Tracker;
use Psr\Http\Message\ServerRequestInterface;

$request = ...; // Your PSR-7 ServerRequestInterface implementation
$tracker = new Tracker($request);

Get Client's IP Address

$ipAddress = $tracker->getIp();

Get Browser Details

$browser = $tracker->getBrowser();
// $browser['name'] contains the browser name
// $browser['version'] contains the browser version

Get Operating System Details

$os = $tracker->getOs();
// $os['name'] contains the OS name
// $os['version'] contains the OS version

Get Device Type

$deviceType = $tracker->getDevice();

Get User Agent

$userAgent = $tracker->getUserAgent();

Get Accepted Languages

$acceptedLanguages = $tracker->getAcceptLangs();

Get Referer URL

$refererUrl = $tracker->getReferer();

Check if Client is Using a Phone Device

$isPhone = $tracker->isPhone();

Get All Client Information

$clientInfo = $tracker->getAll();
// $clientInfo is an associative array containing all client information

IP Tracking Services Integration

Effectra Tracker supports integration with various IP tracking services. Currently, the following services are supported:

IpGeoLocation Service

use Effectra\Tracker\Services\IpGeoLocation;
use GuzzleHttp\Client;

$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query
$apiKey = ...; // Your API key for ipgeolocation.io

$ipGeoLocation = new IpGeoLocation($client, $ip, $apiKey);
$ipAttributes = $ipGeoLocation->getAll();

IpRegistry Service

use Effectra\Tracker\Services\IpRegistry;
use GuzzleHttp\Client;

$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query
$apiKey = ...; // Your API key for ipregistry.co

$ipRegistry = new IpRegistry($client, $ip, $apiKey);
$ipAttributes = $ipRegistry->getAll();

IpWhoIs Service

use Effectra\Tracker\Services\IpWhoIs;
use GuzzleHttp\Client;

$client = new Client(); // GuzzleHttp client instance
$ip = ...; // IP address to query

$ipWhoIs = new IpWhoIs($client, $ip, null); // No API key required for ipwho.is
$ipAttributes = $ipWhoIs->getAll();

Requirements

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固