skeeks / yii2-dadata-client
yii2 api dadata.ru
1.0.0.2
2020-10-22 14:08 UTC
Requires
README
信息
安装
安装此扩展的首选方式是通过 composer.
运行以下命令之一
php composer.phar require --prefer-dist skeeks/yii2-dadata-client "*"
或添加
"skeeks/yii2-dadata-client": "*"
如何使用
//App config [ 'components' => [ //.... 'dadataClient' => [ 'class' => 'skeeks\yii2\dadataClient\dadataClient', 'token' => 'token', 'secret' => 'secret', 'timeout' => 12, ], //.... ] ]
示例
地址提示
$response = \Yii::$app->dadataClient->suggest->address("Москва"); print_r($response); //Array response data
根据IP确定用户位置
$response = \Yii::$app->dadataSuggestApi->detectAddressByIp(\Yii::$app->request->userIP);
电子邮件提示
$response = \Yii::$app->dadataClient->suggest->email("test@ya"); print_r($response); //Array response data
姓名提示
$response = \Yii::$app->dadataClient->suggest->fio("Семен"); print_r($response); //Array response data
SkeekS CMS (Yii2) — 快速、简单、有效!
skeeks.com | cms.skeeks.com