开发者社区> 问答> 正文

PHP使用短信SDK返回ForbiddenUser not authorized to operate on the specified resource

都付笑谈中 2017-04-11 10:41:20 3373

PHP使用短信SDK返回 ForbiddenUser not authorized to operate on the specified resource
代码如下:
<?php

header("Content-type:text/html;charset=utf-8");
//调用短信SDK
include_once 'aliyun-php-sdk-core/Config.php';
use Sms\Request\V20160927 as Sms;

require_once "public.php";
//$config = parse_ini_file('../conf/config.ini', true);
$config = $pgsql->config;

//下发短信
$phoneNumber = 'xxxxxxxxxxx';
$code = '854666';

$iClientProfile = DefaultProfile::getProfile($config['alicloudsms']['City'], $config['alicloudsms']['AccessKeyID'], $config['alicloudsms']['AccessKeySecret']);
$client = new DefaultAcsClient($iClientProfile);
$request = new Sms\SingleSendSmsRequest();
$request->setSignName($config['alicloudsms']['SignName']);/*签名名称*/
$request->setTemplateCode($config['alicloudsms']['VcodeTemplateCode']);/*模板code*/
$request->setRecNum($phoneNumber);/*目标手机号*/
$request->setParamString("{code:$code}");/*模板变量,数字一定要转换为字符串*/
try {
    $response = $client->getAcsResponse($request);
    print_r($response);
}
catch (ClientException  $e) {
    print_r($e->getErrorCode());   
    print_r($e->getErrorMessage());   
}
catch (ServerException  $e) {        
    print_r($e->getErrorCode());   
    print_r($e->getErrorMessage());
}

?>

PHP 开发工具
分享到
取消 提交回答
全部回答(1)
  • jiueasy
    2019-07-17 21:02:26

    我也遇到了这样的问题 请问楼主解决了没有?能否告知如何解决的

    0 0

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题