PHP code example of jimchen / umeng-php-sdk
1. Go to this page and download the library: Download jimchen/umeng-php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jimchen / umeng-php-sdk example snippets
use EasyUmeng\Factory;
$app = Factory::uVerify([
'app_key' => '1234xxxxxxxx',
'ali_key' => '1234xxxxxxxx',
'ali_secret' => '1234xxxxxxxx',
'aes_key' => 'Mnfgxxxxxxxxx',
'response_type' => 'array', // Options: 'collection', 'array', 'object', 'raw'
/**
* 接口请求相关配置,超时时间等,具体可用参数请参考:
* http://docs.guzzlephp.org/en/stable/request-config.html
*
* - retries: 重试次数,默认 1,指定当 http 请求失败时重试的次数。
* - retry_delay: 重试延迟间隔(单位:ms),默认 500
* - log_template: 指定 HTTP 日志模板,请参考:https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php
*/
'http' => [
'max_retries' => 1,
'retry_delay' => 500,
'timeout' => 5.0,
// 'base_uri' => '',
],
/**
* 日志配置
*
* level: 日志级别, 可选为:
* debug/info/notice/warning/error/critical/alert/emergency
* path:日志文件位置(绝对路径!!!),要求可写权限
*
* 如果不进行配置则会使用默认选项,可查看 EasyUmeng\Kernel\Providers\LogServiceProvider::formatLogConfig
*/
'log' => [
'default' => 'dev', // 默认使用的 channel,生产环境可以改为下面的 prod
'channels' => [
// 测试环境
'dev' => [
'driver' => 'single',
'path' => '/tmp/easyumeng.log',
'level' => 'debug',
],
// 生产环境
'prod' => [
'driver' => 'daily',
'path' => '/tmp/easyumeng.log',
'level' => 'info',
],
],
],
]);
/**
* 一键登录
* @link https://developer.umeng.com/docs/143070/detail/144783
*/
$result1 = $app->info->get($token, $verifyId);
/**
* 本机号码认证
* @link https://developer.umeng.com/docs/143070/detail/144784
*/
$result2 = $app->verify->handle($phone, $token, $verifyId);
shell
$ composer