68 lines
1.3 KiB
PHP
68 lines
1.3 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年11月15日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
namespace UniLbs;
|
||
|
||
use Curl\Curl;
|
||
|
||
class UniLbs
|
||
{
|
||
public $key;
|
||
/**
|
||
* 地图接口提供商,qqmap=腾讯,amap=高德,baidu=百度
|
||
*/
|
||
public $provider;
|
||
public $curl;
|
||
|
||
public $plugin;
|
||
|
||
|
||
public function __construct($key, $provider = "qqmap") {
|
||
$this->key = $key;
|
||
$this->provider = $provider;
|
||
$this->init();
|
||
}
|
||
|
||
public function init()
|
||
{
|
||
$this->curl = new Curl();
|
||
if($this->provider == 'qqmap'){
|
||
$this->plugin = new Qqmap($this);
|
||
}
|
||
return $this;
|
||
}
|
||
|
||
public function buildRequest($api, $data = [], $method = 'get')
|
||
{
|
||
$method = strtolower($method);
|
||
if($method == 'get'){
|
||
$this->curl->get($api, $data);
|
||
}
|
||
if($method == 'post'){
|
||
$this->curl->post($api, $data);
|
||
}
|
||
}
|
||
|
||
|
||
public function getUrlQuery($params = [], $prefix = '?')
|
||
{
|
||
$tmp = [];
|
||
foreach ($params as $key => $val){
|
||
$val = trim($val);
|
||
$tmp[] = "{$key}={$val}";
|
||
}
|
||
$query = implode('&', $tmp);
|
||
return $prefix ? $prefix . $query : $query;
|
||
}
|
||
|
||
}
|
||
|