承接 chinafuturelink/geo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

chinafuturelink/geo

最新稳定版本:2.2.4

Composer 安装命令:

composer require chinafuturelink/geo

包简介

Location Services of FutureLink

README 文档

README

CircleCI codecov

ChinaFutureLink/GEO

提供地理服务相关接口。

Installing / Getting started

通过Composer安装

composer require fu/geo 2.*

将下面的代码加入composer.json

{
    "require": {
    	"fu/geo": "2.*"
    }
}

Developing

Building

> vendor/bin/phpcs --standard=PSR12 src
> vendor/bin/phpcbf --standard=PSR12 src
> vendor/bin/phpunit 

Generating code coverage report in HTML format ... done [00:00.020]

Features

根据经纬度查询地理位置信息

include "./vendor/autoload.php";

use Fu\Geo\GeoCoder;
use Fu\Geo\Service\Coordinary\TencentCoordinaryLocationService;

const KEY = "YOUR-TENCENT-GEO-SERVICE-KEY";

$latitude  = 29.60001;
$longitude = 91.00001;

$service = new TencentCoordinaryLocationService(KEY);
$response = $service->getLocation($latitude, $longitude);

if ($response->isOk()) {
    $area = $response->getArea();
    $area->nation; // 中国
    $area->lv1;    // 西藏自治区
    $area->lv2;    // 拉萨市
    $area->lv3;    // 堆龙德庆区
} else {
    // get the response raw data...
    var_dump($response->getRaw());   
}

根据IP地址查询地理位置信息

include "./vendor/autoload.php";

use Fu\Geo\IpCoder;
use Fu\Geo\Service\Ip\TencentIpLocationService;

const KEY = "YOUR-TENCENT-GEO-SERVICE-KEY";

$ip = '171.221.208.34';
$service = new TencentIpLocationService(KEY);
$response = $service->getLocation($ip);

if ($response->isOk()) {
    $area = $response->getArea()
    $area->nation; // 中国
    $area->lv1;    // 四川省
    $area->lv2;    // 成都市
    $area->lv3;    // 温江区
} else {
    // get the response raw data...
    var_dump($response->getRaw());
}

根据手机号码查询地理位置信息

include "./vendor/autoload.php";

use Fu\Geo\IpCoder;
use Fu\Geo\Service\Phone\AliPhoneLocationService;

const KEY = "YOUR-ALI-SERVICE-KEY";

$areaCode = '86';
$phone = '13880799123';
$service = new AliPhoneLocationService(KEY);
$response = $service->getLocation($areaCode, $phone);

if ($response->isOk()) {
    $area = $response->getArea()
    $area->nation; // 中国
    $area->lv1;    // 四川省
    $area->lv2;    // 成都市
    $area->lv3;    // 温江区
} else {
    // get the response raw data...
    var_dump($response->getRaw());
}

Links

Licensing

The code in this project is licensed under MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固