当前位置: 首页>>代码示例>>PHP>>正文


PHP Ostatus_profile::ensureWebfinger方法代码示例

本文整理汇总了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;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:59,代码来源:ostatussub.php

示例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;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:29,代码来源:Ostatus_profile.php

示例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;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:32,代码来源:Ostatus_profile.php

示例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;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:31,代码来源:OStatusPlugin.php


注:本文中的Ostatus_profile::ensureWebfinger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。