开发者社区> 问答> 正文

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

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());
}

?>

展开
收起
都付笑谈中 2017-04-11 10:41:20 8719 0
1 条回答
写回答
取消 提交回答
  • 我也遇到了这样的问题 请问楼主解决了没有?能否告知如何解决的

    2019-07-17 21:02:26
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云栖开发者沙龙PHP技术专场-深入浅出网络编程与swoole内核-吴镇宇 立即下载
PHP安全开发:从白帽角度做安全 立即下载
PHP 2017.北京 全球开发者大会——高可用的PHP 立即下载