我尝试将json_decode更改为json_encode,但错误转为为foreach()提供的无效参数。
public function getCloudsList(){
$clouds = array();
try {
$apiManager = new ApiManager();
$oauthManager = new OAuthManager();
$user = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
$response = json_decode($apiManager->getCloudsList());
foreach ($response as $cloud) {
$isActive = false;
$token = $oauthManager->getTokenUserCloud($user, $cloud);
if ($token) {
if (strlen($token->getTsecret()) > 0) {
$isActive = true;
$tokenAux = new stdClass();
$tokenAux->key = $token->getTKey();
$tokenAux->secret =$token->getTSecret();
$_SESSION['access_token_' . $cloud . '_v2'] = $tokenAux;
}
}
array_push($clouds, array("name" => $cloud, "isActive" => $isActive));
}
} catch (Exception $e){
throw new Exception($e->getMessage());
}
return $clouds;
}