phpsms
phpsms copied to clipboard
腾讯的接口1004错误
出现1004错误
[{"driver":"Qcloud","time":{"started_at":"0.33102900 1507352277","finished_at":"0.60767200 1507352277"},"success":false,"result":{"info":"{\"result\":1004,\"errmsg\":\"package format errorcannot get \/tel\/mobile\"}","code":1004}}]
我也是...我去,折腾了一天了
@ahu 你是怎么修复的?
@youngerrainbow 未及修复...先绕开了
@ahu 好像官方有兼容,是不是哪里调用不对?
@youngerrainbow 只能等回头细看了:)
@ahu post 格式不对,给成 json 数组用 数字key 就可以了,我测试ok了
@youngerrainbow 具体怎么改?
@DreamboyA @youngerrainbow 我是直接修改了 QcloudAgent.php 把所有 'tel'=>$to 改为了 'tel' => ['nationcode' => '86', 'mobile' => $to] 解决的。另外需要注意的是template date 里定义的参数一定要跟你申请的模板一致
@ahu 多谢你的分享。这个问题,还需要把format_mobile 方法注释掉。
@dm521 @ahu 多谢分享,我修改QcloudAgent.php 中的formatMobile,可以正常发送
public function formatMobile(array $list)
{
$list = array_map(function ($value) {
return [
'nationcode' => $value['nation'],
'mobile' => $value['number'],
];
}, array_filter($list, function ($value) {
return is_array($value);
}));
return count($list) === 1 ? array_pop($list) : array_values($list);
}
修改为:
public function formatMobile(array $list)
{
$list = array_map(function ($value) {
return [
'nationcode' => is_string($value) ? '86' : $value['nation'],
'mobile' => is_string($value) ? $value : $value['number'],
];
}, array_filter($list, function ($value) {
return is_array($value) || is_string($value);
}));
return count($list) === 1 ? array_pop($list) : array_values($list);
}