链街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.

98 lines
2.2 KiB

5 years ago
  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. use Illuminate\Support\Facades\Log;
  9. class Test extends AdminController
  10. {
  11. public function sentSms()
  12. {
  13. $params = [
  14. 'RegionId' => "cn-shenzhen",
  15. 'PhoneNumbers' => "13481194554",
  16. 'SignName' => "��������",
  17. 'TemplateCode' => "SMS_201720790",
  18. 'TemplateParam' => json_encode(['name'=>'DESION','money'=>999]),
  19. ];
  20. AlibabaCloud::accessKeyClient(env('OSS_ACCESS_ID'),env('OSS_ACCESS_SECRET'))
  21. ->regionId('cn-shenzhen')
  22. ->asDefaultClient();
  23. try {
  24. $result = AlibabaCloud::rpc()
  25. ->product('Dysmsapi')
  26. ->version('2017-05-25')
  27. ->action('SendSms')
  28. ->method('POST')
  29. ->host('dysmsapi.aliyuncs.com')
  30. ->options([
  31. 'query' => $params
  32. ])
  33. ->request();
  34. dd($result);
  35. }catch (ClientException $e){
  36. echo $e->getErrorMessage() . PHP_EOL;
  37. }catch (ServerException $e){
  38. echo $e->getErrorMessage() . PHP_EOL;
  39. }
  40. }
  41. public function testRpc()
  42. {
  43. $client = Client::factory(env('RPC_SITE_HOST'));
  44. $request = $client->request(uniqid(),'/alisms/sent', [
  45. 'phone' => 13481194554,
  46. 'template'=>'SMS_201720790',
  47. 'templateParams'=> json_encode(['name'=>"[DESION]",'money'=>'200Ԫ']),
  48. ]);
  49. $response = $client->send($request);
  50. $result = json_decode($response->getBody()->getContents());
  51. if ($result->result->Code != 'OK') {
  52. $msg = $result->result->Message;
  53. Log::error('���Ͷ���ʧ��', ['Message'=>$msg]);
  54. }
  55. return $response->getBody()->getContents();
  56. }
  57. public function getOrderDetail()
  58. {
  59. $oid = request()->get('oid');
  60. $order = ImsCjdcOrderMain::where('id',$oid)->first();
  61. return $order;
  62. }
  63. }