本文整理汇总了PHP中CommonFunctions::fromJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonFunctions::fromJSON方法的具体用法?PHP CommonFunctions::fromJSON怎么用?PHP CommonFunctions::fromJSON使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonFunctions
的用法示例。
在下文中一共展示了CommonFunctions::fromJSON方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validates current session at Registry side
*
* @return json
*/
public function validate($cltrid = false)
{
$json = ApiRequest::GET('/auth', $cltrid ?: ApiRequest::defaultClientTransactionID(), $this->getAuthToken());
$response = CommonFunctions::fromJSON($json);
if ($response->code == 1000) {
$this->_sessionData['expires'] = $response->result['expires'];
}
return $json;
}
示例2: exist
/**
* Check if host already exist at ST Registry
*
* @param str $hostname
*
* @return boolean
*/
public function exist($hostname, $cltrid = false)
{
$json = ApiRequest::GET(sprintf("/hosts/%s/check", $hostname), $cltrid ?: ApiRequest::defaultClientTransactionID(), STRegistry::Session()->getAuthToken());
$response = CommonFunctions::fromJSON($json);
return (bool) (!$response->result['avail']);
}
示例3: fromJSON
/**
* Create Contact object from json string
*
* @param str $json json string representing contact state
*
* @return Contact
*/
public static function fromJSON($json)
{
$data = CommonFunctions::fromJSON($json, 'info')->result;
$contact = new Contact();
$contact->setContactId($data['id'])->setEmail($data['email'])->setPhoneNumber($data['voice'])->setFaxNumber($data['fax']);
foreach (array(Contact::POSTALINFO_INT, Contact::POSTALINFO_LOCAL) as $type) {
if (isset($data['postalInfo'][$type])) {
$pi = $data['postalInfo'][$type];
$contact->setName($pi['name'], $type)->setOrganization($pi['org'], $type)->setAddress(@$pi['addr']['street'][0], @$pi['addr']['street'][1], @$pi['addr']['street'][2])->setCity($pi['addr']['city'])->setCountryCode($pi['addr']['cc'])->setState($pi['addr']['sp'])->setPostalCode($pi['addr']['pc']);
}
}
return $contact;
}
示例4: fromJSON
/**
* Create Domain object from json string
*
* @param str $json json string representing domain state
*
* @return Domain
*/
public static function fromJSON($json)
{
$data = CommonFunctions::fromJSON($json, 'info')->result;
$domain = new Domain($data['name']);
$domain->setContacts($data['contacts'][Domain::CONTACT_TYPE_REGISTRANT], $data['contacts'][Domain::CONTACT_TYPE_ADMIN], $data['contacts'][Domain::CONTACT_TYPE_TECH], $data['contacts'][Domain::CONTACT_TYPE_BILLING])->setPrivacyContacts(@$data['contacts'][Domain::CONTACT_TYPE_REGISTRANT_PRIVACY], @$data['contacts'][Domain::CONTACT_TYPE_ADMIN_PRIVACY], @$data['contacts'][Domain::CONTACT_TYPE_TECH_PRIVACY], @$data['contacts'][Domain::CONTACT_TYPE_BILLING_PRIVACY])->setDateCreated($data['crDate'])->setDateExpire($data['exDate'])->setAuthCode($data['authInfo']['pw']);
if (isset($data['ns']) && count($data['ns'])) {
foreach ($data['ns'] as $nameserver) {
$domain->addNameServer($nameserver);
}
}
foreach ($data['status'] as $status) {
$domain->addStatus($status);
}
return $domain;
}
示例5: fromJSON
/**
* Create Host object from json string
*
* @param str $json json string representing domain state
*
* @return Host
*/
public static function fromJSON($json)
{
$data = CommonFunctions::fromJSON($json, 'info')->result;
$host = new Host($data['name']);
foreach ($data['addr'] as $addr) {
$keys = array_keys($addr);
$version = array_shift($keys);
if ($version == Host::IP_VERSION_4) {
$host->addIPv4($addr[$version]);
} else {
$host->addIPv6($addr[$version]);
}
}
foreach ($data['status'] as $status) {
$host->addStatus($status);
}
return $host;
}