本文整理汇总了PHP中Ostatus_profile::ensureWebfinger方法的典型用法代码示例。如果您正苦于以下问题:PHP Ostatus_profile::ensureWebfinger方法的具体用法?PHP Ostatus_profile::ensureWebfinger怎么用?PHP Ostatus_profile::ensureWebfinger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ostatus_profile
的用法示例。
在下文中一共展示了Ostatus_profile::ensureWebfinger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pullRemoteProfile
/**
* Pull data for a remote profile and check if it's valid.
* Fills out error UI string in $this->error
* Fills out $this->oprofile on success.
*
* @return boolean
*/
function pullRemoteProfile()
{
$this->profile_uri = $this->trimmed('profile');
try {
if (Validate::email($this->profile_uri)) {
$this->oprofile = Ostatus_profile::ensureWebfinger($this->profile_uri);
} else {
if (Validate::uri($this->profile_uri)) {
$this->oprofile = Ostatus_profile::ensureProfileURL($this->profile_uri);
} else {
// TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
// TRANS: and example.net, as these are official standard domain names for use in examples.
$this->error = _m("Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.");
common_debug('Invalid address format.', __FILE__);
return false;
}
}
return true;
} catch (FeedSubBadURLException $e) {
// TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
// TRANS: and example.net, as these are official standard domain names for use in examples.
$this->error = _m('Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.');
common_debug('Invalid URL or could not reach server.', __FILE__);
} catch (FeedSubBadResponseException $e) {
// TRANS: Error text.
$this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
common_debug('Cannot read feed; server returned error.', __FILE__);
} catch (FeedSubEmptyException $e) {
// TRANS: Error text.
$this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
common_debug('Cannot read feed; server returned an empty page.', __FILE__);
} catch (FeedSubBadHTMLException $e) {
// TRANS: Error text.
$this->error = _m('Sorry, we could not reach that feed. Please try that OStatus address again later.');
common_debug('Bad HTML, could not find feed link.', __FILE__);
} catch (FeedSubNoFeedException $e) {
// TRANS: Error text.
$this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
common_debug('Could not find a feed linked from this URL.', __FILE__);
} catch (FeedSubUnrecognizedTypeException $e) {
// TRANS: Error text.
$this->error = _m("Sorry, we could not reach that feed. Please try that OStatus address again later.");
common_debug('Not a recognized feed type.', __FILE__);
} catch (Exception $e) {
// Any new ones we forgot about
// TRANS: Error message in OStatus plugin. Do not translate the domain names example.com
// TRANS: and example.net, as these are official standard domain names for use in examples.
$this->error = _m("Sorry, we could not reach that address. Please make sure that the OStatus address is like nickname@example.com or http://example.net/nickname.");
common_debug(sprintf('Bad feed URL: %s %s', get_class($e), $e->getMessage()), __FILE__);
}
return false;
}
示例2: ensureProfileURI
static function ensureProfileURI($uri)
{
$oprofile = null;
// First, try to query it
$oprofile = Ostatus_profile::staticGet('uri', $uri);
// If unfound, do discovery stuff
if (empty($oprofile)) {
if (preg_match("/^(\\w+)\\:(.*)/", $uri, $match)) {
$protocol = $match[1];
switch ($protocol) {
case 'http':
case 'https':
$oprofile = Ostatus_profile::ensureProfileURL($uri);
break;
case 'acct':
case 'mailto':
$rest = $match[2];
$oprofile = Ostatus_profile::ensureWebfinger($rest);
break;
default:
throw new ServerException("Unrecognized URI protocol for profile: {$protocol} ({$uri})");
break;
}
} else {
throw new ServerException("No URI protocol for profile: ({$uri})");
}
}
return $oprofile;
}
示例3: ensureProfileURI
static function ensureProfileURI($uri)
{
$oprofile = null;
// First, try to query it
$oprofile = Ostatus_profile::staticGet('uri', $uri);
// If unfound, do discovery stuff
if (empty($oprofile)) {
if (preg_match("/^(\\w+)\\:(.*)/", $uri, $match)) {
$protocol = $match[1];
switch ($protocol) {
case 'http':
case 'https':
$oprofile = Ostatus_profile::ensureProfileURL($uri);
break;
case 'acct':
case 'mailto':
$rest = $match[2];
$oprofile = Ostatus_profile::ensureWebfinger($rest);
break;
default:
// TRANS: Server exception.
// TRANS: %1$s is a protocol, %2$s is a URI.
throw new ServerException(sprintf(_m('Unrecognized URI protocol for profile: %1$s (%2$s).'), $protocol, $uri));
break;
}
} else {
// TRANS: Server exception. %s is a URI.
throw new ServerException(sprintf(_m('No URI protocol for profile: %s.'), $uri));
}
}
return $oprofile;
}
示例4: pullRemoteProfile
protected function pullRemoteProfile($arg)
{
$oprofile = null;
if (preg_match('!^((?:\\w+\\.)*\\w+@(?:\\w+\\.)*\\w+(?:\\w+\\-\\w+)*\\.\\w+)$!', $arg)) {
// webfinger lookup
try {
return Ostatus_profile::ensureWebfinger($arg);
} catch (Exception $e) {
common_log(LOG_ERR, 'Webfinger lookup failed for ' . $arg . ': ' . $e->getMessage());
}
}
// Look for profile URLs, with or without scheme:
$urls = array();
if (preg_match('!^https?://((?:\\w+\\.)*\\w+(?:\\w+\\-\\w+)*\\.\\w+(?:/\\w+)+)$!', $arg)) {
$urls[] = $arg;
}
if (preg_match('!^((?:\\w+\\.)*\\w+(?:\\w+\\-\\w+)*\\.\\w+(?:/\\w+)+)$!', $arg)) {
$schemes = array('http', 'https');
foreach ($schemes as $scheme) {
$urls[] = "{$scheme}://{$arg}";
}
}
foreach ($urls as $url) {
try {
return Ostatus_profile::ensureProfileURL($url);
} catch (Exception $e) {
common_log(LOG_ERR, 'Profile lookup failed for ' . $arg . ': ' . $e->getMessage());
}
}
return null;
}