skeeks/yii2-dadata-client

yii2 api dadata.ru

安装次数: 6,135

依赖: 1

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

类型:yii2-extension

1.0.0.2 2020-10-22 14:08 UTC

This package is auto-updated.

Last update: 2024-09-05 17:22:02 UTC


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!
SkeekS CMS (Yii2) — 快速、简单、有效!
skeeks.com | cms.skeeks.com