regionId(config('aliyun.region_id')) ->asDefaultClient(); $templateParam = [ "code" => $code ]; try { $result = AlibabaCloud::rpc() ->product('Dysmsapi') // ->scheme('https') // https | http ->version('2017-05-25') ->action('SendSms') ->method('POST') ->host(config('aliyun.host')) ->options([ 'query' => [ 'RegionId' => "cn-hangzhou", 'PhoneNumber' => $phone, 'SingName' => config('aliyun.sign_name'), 'TemplateCode' => config('aliyun.template_code'), 'TemplateParam' => json_encode($templateParam) ], ]) ->request(); Log::info("alisms-sendCode-{$phone}-result" . json_encode($result->toArray())); // print_r($result->toArray()); } catch (ClientException $e) { Log::error("alisms-sendCode-{$phone}-ClientException" . $e->getErrorMessage()); return false; // echo $e->getErrorMessage() . PHP_EOL; } catch (ServerException $e) { Log::error("alisms-sendCode-{$phone}-ServerException" . $e->getErrorMessage()); return false; // echo $e->getErrorMessage() . PHP_EOL; } if (isset($result['Code']) && $result['Code'] === 'OK') { return true; } return false; } }