百度APIStore免费接口封装
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist light/apistore "*"
or add
"light/apistore": "*"
to the require section of your composer.json
file.
Once the extension is installed, simply use it in your code by :
$store = new light\apistore\ApiStore('your key');
$api = $store->phone;
$result = $api->get('15292312331');
if ($result['errcode'] == 0) {
var_dump($result['data']);
} else {
echo 'Get error: ', $result['errmsg'];
}
目前可用接口:
$store->phone
$store->idcard
$store->translate
$sotre->ip
$sotre->currency
$sotre->pullword
$sotre->distance
如果你发现需要的接口目前没有,可以发起pull request进行提交.
流程是在src/apis
建立新的接口调用类,新的接口需要继承自light\apistore\apis\Api
, 大概如下:
class Sms extends Api
{
private $address = 'http://apiurl';
public function get($params)
{
return $this->fetch($this->address . http_build_query($params));
}
}
这个库确实不错,百度提供的这个 api store ,我早已经加入本站的酷站