链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.6 KiB

  1. <?php
  2. namespace App\Admin\Controllers;
  3. use AlibabaCloud\Client\AlibabaCloud;
  4. use AlibabaCloud\Client\Exception\ClientException;
  5. use AlibabaCloud\Client\Exception\ServerException;
  6. use Dcat\Admin\Controllers\AdminController;
  7. use Graze\GuzzleHttp\JsonRpc\Client;
  8. class Test extends AdminController
  9. {
  10. public function sentSms()
  11. {
  12. $params = [
  13. 'RegionId' => "cn-shenzhen",
  14. 'PhoneNumbers' => "13481194554",
  15. 'SignName' => "懒族生活",
  16. 'TemplateCode' => "SMS_201720790",
  17. 'TemplateParam' => json_encode(['name'=>'DESION','money'=>999]),
  18. ];
  19. AlibabaCloud::accessKeyClient(env('OSS_ACCESS_ID'),env('OSS_ACCESS_SECRET'))
  20. ->regionId('cn-shenzhen')
  21. ->asDefaultClient();
  22. try {
  23. $result = AlibabaCloud::rpc()
  24. ->product('Dysmsapi')
  25. ->version('2017-05-25')
  26. ->action('SendSms')
  27. ->method('POST')
  28. ->host('dysmsapi.aliyuncs.com')
  29. ->options([
  30. 'query' => $params
  31. ])
  32. ->request();
  33. dd($result);
  34. }catch (ClientException $e){
  35. echo $e->getErrorMessage() . PHP_EOL;
  36. }catch (ServerException $e){
  37. echo $e->getErrorMessage() . PHP_EOL;
  38. }
  39. }
  40. public function testRpc()
  41. {
  42. $client = Client::factory('http://store.api.lanzulive.com:9505');
  43. $request = $client->request(uniqid(),'/myrpc/mymethod', ['args' => null]);
  44. $response = $client->send($request);
  45. return $response->getBody()->getContents();
  46. }
  47. }