flc1125 / alidayu

阿里大于(鱼)API接口-SDK
http://flc.io/2016/09/563.html
MIT License
181 stars 63 forks source link

报错Warning: current() expects parameter 1 to be array, null given in vendor\flc\alidayu\src\Alidayu\Client.php on line 129 #6

Closed xualen closed 7 years ago

xualen commented 7 years ago

代码如下: require '/vendor/flc/alidayu/autoload.php'; use Flc\Alidayu\Client; use Flc\Alidayu\App; use Flc\Alidayu\Requests\AlibabaAliqinFcSmsNumSend; use Flc\Alidayu\Requests\IRequest;

// 配置信息 $config = array( 'app_key' => '......', 'app_secret' => '......' );

// 使用方法一 $client = new Client(new App($config)); $req = new AlibabaAliqinFcSmsNumSend;

$req->setRecNum('13000000000') ->setSmsParam([ 'number' => rand(100000, 999999) ]) ->setSmsFreeSignName('...') ->setSmsTemplateCode('SMS_10000000');

$resp = $client->execute($req); 报错: Warning: current() expects parameter 1 to be array, null given in E:\web\vendor\flc\alidayu\src\Alidayu\Client.php on line 129

royalwang commented 7 years ago

你的请求返回值是Null,json解析空也是Null,然后用来current取值就报参数应该是个数组,不能用Null值。

flc1125 commented 7 years ago

是的。一般出現這種情況,是網絡原因導致的。建議在最外層增加一個try catch

Tinywan commented 7 years ago
Tinywan commented 7 years ago

@xualen 这个问题你解决了没有?

flc1125 commented 7 years ago

这块我重新发布一个版本专门修复下吧!

flc1125 commented 7 years ago

已修复。已更新packagist

Tinywan commented 7 years ago

@flc1125 可以的