本文整理汇总了PHP中Domain::setContacts方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::setContacts方法的具体用法?PHP Domain::setContacts怎么用?PHP Domain::setContacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::setContacts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stregistry_RegisterDomain
/**
* make domain registration api call
*
* @param array $params call params with domain details
*
* @return mixed array containig error message will return if error was ocurred, 'success' string in other case
*/
function stregistry_RegisterDomain($params)
{
// init connection
if (($status = __initConnectionAndAuthorize($params)) !== true) {
return __errorArray($status);
}
$domain = new Domain($params['domainname']);
// create domain contacts
$contactIds = array();
foreach (array('registrant', 'admin', 'tech', 'billing') as $contactType) {
$contact = new Contact();
$contact->setEmail($params['email'])->setPhoneNumber($params['phonenumberformatted'] ?: '')->setName($params['fullname'])->setOrganization($params['companyname'])->setAddress($params['address1'], $params['address1'] ?: '')->setCity($params['city'])->setState($params['fullstate'])->setPostalCode($params['postcode'])->setCountryCode($params['countrycode']);
$json = STRegistry::Contacts()->create($contact);
if (!ResponseHelper::isSuccess($json)) {
return __errorArray(ResponseHelper::fromJSON($json)->message);
}
$contactIds[$contactType] = ResponseHelper::fromJSON($json, 'creData')->result['id'];
}
$domain->setContacts($contactIds['registrant'], $contactIds['admin'], $contactIds['tech'], $contactIds['billing']);
if ($params['idprotection']) {
$domain->setPrivacyContacts(STRegistryPrivacyContact::getRegistrantId(), STRegistryPrivacyContact::getAdminId(), STRegistryPrivacyContact::getTechId(), STRegistryPrivacyContact::getBillingId());
}
// add nameservers
foreach (array('ns1', 'ns2', 'ns3', 'ns4', 'ns5') as $nsKey) {
if (!empty($params[$nsKey])) {
$domain->addNameServer($params[$nsKey]);
}
}
// creating domain
$json = STRegistry::Domains()->create($domain, $params['regperiod']);
if (!ResponseHelper::isSuccess($json)) {
return __errorArray(ResponseHelper::fromJSON($json)->message);
}
return 'success';
}
示例2: 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;
}