cxgj/cxe/unilbs/src/UniLbs/UniLbs.php
2023-11-27 09:45:13 +08:00

68 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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;
}
}