jjonline / aliyun-dysms-php-sdk

阿里云-云通信PHP版sdk精简,非原先阿里大于SDK,原阿里大鱼被合并进了“阿里云-云通信”,SDK已变化
Apache License 2.0
21 stars 6 forks source link

ErrorException : Invalid argument supplied for foreach() #4

Closed ndj888 closed 3 years ago

ndj888 commented 6 years ago

/opt/project/vendor/huaifufeng/aliyun-sts/src/Core/Profile/DefaultProfile.php:107 /opt/project/vendor/huaifufeng/aliyun-sts/src/Core/Profile/DefaultProfile.php:94

public static function findEndpointByName($endpointName) { foreach (self::$endpoints as $key => $endpoint) { if($endpoint->getName() == $endpointName) { return $endpoint; } } }

经调试 self::$endpoints 为 null ,故抛出异常

jjonline commented 6 years ago

初始化的时候要传入endpoints参数,README有调用示例

// 初始化用户Profile实例
$profile = DefaultProfile::getProfile("cn-hangzhou", $appKey, $appSecret);
DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com");
$acsClient = new DefaultAcsClient($profile);