1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php namespace App\Http\Controllers\Api;
- use AlibabaCloud\SDK\Dyvmsapi\V20170525\Dyvmsapi;
- use \Exception;
- use AlibabaCloud\Tea\Exception\TeaError;
- use AlibabaCloud\Tea\Utils\Utils;
- use Darabonba\OpenApi\Models\Config;
- use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\SingleCallByTtsRequest;
- use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
- use App\Facades\Servers\Logs\Log;
- /**
- * 测试接口
- *
- * @author 刘相欣
- *
- * */
- class Test extends Api{
-
-
- /**
- * 同步 /api/test/sync_user
- *
- * */
- public function sync_user(){
- // 获取三天后到期的优惠券->addDays(3)
- $list = $Model->query()->where([['status','=',0],['exp_time','>',now()->createFromTimestamp(1741338720)->startOfDay()->getTimestamp()],['exp_time','<',now()->createFromTimestamp(1741338720)->endOfDay()->getTimestamp()]])->pluck('coupon_id','custom_uid')->toArray();
- // 通过列表查询对应的客户手机号
- $phoneList = $Custom->query()->whereIn('uid',array_keys($list))->pluck('phone')->toArray();
- // 给这些手机号发送一条阿里云短信
- $phoneList = implode(',',$phoneList);
- dd($phoneList);
-
- Log::error("测试接口",'测试接口',request()->all());
- return response()->json(["code"=> 0,"msg"=>"成功"]);
- self::main();
- }
- /**
- * 使用AK&SK初始化账号Client
- * @return Dyvmsapi Client
- */
- public static function createClient(){
- // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
- // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/311677.html
- $config = new Config(["accessKeyId" => 'LTAI5tDwjfteBvivYN41r8sJ', "accessKeySecret" => 'yowuOGi2nYYnrqGpO3qcz94C4brcPp']);
- // Endpoint 请参考 https://api.aliyun.com/product/Dyvmsapi
- $config->endpoint = "dyvmsapi.aliyuncs.com";
- return new Dyvmsapi($config);
- }
- /**
- * @param string[] $args
- * @return void
- */
- public static function main(){
- $client = self::createClient();
- $singleCallByTtsRequest = new SingleCallByTtsRequest([
- 'calledNumber' => '18610028595',
- 'ttsCode' => 'TTS_307425151',
- 'ttsParam' => '{"name":"刘先生","task":"11"}',
- 'playTimes' => 1
- ]);
- $runtime = new RuntimeOptions([]);
- try {
- // 复制代码运行请自行打印 API 的返回值
- $result = $client->singleCallByTtsWithOptions($singleCallByTtsRequest, $runtime);
- dd($result->toMap());
- }
- catch (Exception $error) {
- if (!($error instanceof TeaError)) {
- $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
- }
- // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
- // 错误 message
- var_dump($error->message);
- // 诊断地址
- var_dump($error->data["Recommend"]);
- Utils::assertAsString($error->message);
- }
- }
- }
|