兼容写法:也可直接将参数 token / sign / timestamp / nonce 拼接在URL参数中(参数说明请对应上方,Token无需“Bearer”),不建议此方式,安全性较低,容易泄露隐私数据。
该API可广泛应用于需要动态问候的交互场景。例如,在网站或应用的用户登录、个人中心、仪表盘首页,可以根据用户访问的实际时间点(如上午、中午、晚上)自动切换展示“早上好”、“下午好”等问候语,并结合具体日期与星期信息,营造更贴心、智能的用户体验,增强产品的亲和力与时效性。
适用于: Laravel / ThinkPHP 6.x 8.x / Hyperf / Symfony / Yii2 / Slim / CodeIgniter4 等主流 PHP 框架及原生 PHP 项目,更多语言SDK陆续开发中。
composer require isas/php-sdk
git clone https://github.com/ISAS-DATA/isas-php-sdk.git
use Isas\Sdk\Client as IsasSdk; $isas = new IsasSdk($token, $appSecret); $isas->Tools()->currentTimeGreeting();
use Isas\Sdk\Client as IsasSdk; $isas = new IsasSdk($token, $appSecret); $Tools = new \Isas\Sdk\Services\Tools($isas); $Tools->currentTimeGreeting();
<?php require_once __DIR__ . '/vendor/autoload.php'; use Isas\Sdk\Client as IsasSdk; // 配置你的凭证 $token = 'YOUR_API_TOKEN'; $appSecret = 'YOUR_APP_SECRET'; // 未启用动态签名服务可留空 // 初始化客户端 $isas = new IsasSdk($token, $appSecret); // 调用 [ 当前时间温馨提示 ] 服务接口 // 方式一:链式极简调用(基于动态代理魔术方法(__call)实现子服务路由切换) $response = $isas->Tools()->currentTimeGreeting(); // 方式二:独立服务实例调用(显式实例化服务组件,适用于提供 IDE 强类型代码补全提示的场景) // $Tools = new \Isas\Sdk\Services\Tools($isas); // $response = $Tools->currentTimeGreeting(); // 输出结果 if ($response['code'] === 200) { echo "获取成功:"; print_r($response['data']); } else { echo "错误:" . $response['message']; } ?>