本文整理汇总了PHP中StringHelper::isJson方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::isJson方法的具体用法?PHP StringHelper::isJson怎么用?PHP StringHelper::isJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::isJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeAction
public static function executeAction($instanceAction, $account, $instanceID)
{
$response = '';
switch ($instanceAction) {
case 'start':
$response = self::getDriver($account)->startInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
break;
case 'stop':
$response = self::getDriver($account)->stopInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
break;
case 'restart':
$response = self::getDriver($account)->restartInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
break;
case 'terminate':
$response = self::getDriver($account)->terminateInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
break;
case 'describeInstances':
$response = self::getDriver($account)->describeInstances(array('DryRun' => false, 'InstanceIds' => array($instanceID)));
break;
case 'downloadKey':
$responseJson = xDockerEngine::authenticate(array('username' => Auth::user()->username, 'password' => md5(Auth::user()->engine_key)));
EngineLog::logIt(array('user_id' => Auth::id(), 'method' => 'authenticate-executeAction', 'return' => $responseJson));
$obj = json_decode($responseJson);
if (!empty($obj) && $obj->status == 'OK') {
$response = xDockerEngine::downloadKey(array('token' => $obj->token, 'cloudProvider' => $account->cloudProvider, 'instanceRegion' => $account->instanceRegion));
Log::info('downloadKey Json:' . $response);
if (StringHelper::isJson($response)) {
$response = json_decode($response, true);
$response['message'] = 'Key is returned in field key';
} else {
$response = array('status' => 'error', 'message' => 'Error occured while downloading keys');
}
} else {
if (!empty($obj) && $obj->status == 'error') {
Log::error('Error occured while downloading key' . $obj->message);
$response = array('status' => $obj->status, 'message' => 'Unexpected error! Contact Support');
} else {
Log::error('Error occured while downloading key');
$response = array('status' => 'error', 'message' => 'Unexpected error! Contact Support');
}
}
break;
}
return $response;
}
示例2: getxDockerServiceStatus
public static function getxDockerServiceStatus()
{
$responseJson = xDockerEngine::authenticate(array('username' => Auth::user()->username, 'password' => md5(Auth::user()->engine_key)));
EngineLog::logIt(array('user_id' => Auth::id(), 'method' => 'getxDockerServiceStatus : authenticate', 'return' => $responseJson));
$status = 'error';
if (StringHelper::isJson($responseJson)) {
$obj = json_decode($responseJson);
if (!empty($obj) && $obj->status == 'OK') {
$status = 'OK';
}
}
return $status;
}
示例3: getStatus
public static function getStatus($json)
{
if (StringHelper::isJson($json)) {
$obj = json_decode($json);
return self::getLabel($obj->status);
} else {
return self::getLabel('error');
}
}