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


PHP Ostatus_profile::ensureProfileURL方法代码示例

本文整理汇总了PHP中Ostatus_profile::ensureProfileURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Ostatus_profile::ensureProfileURL方法的具体用法?PHP Ostatus_profile::ensureProfileURL怎么用?PHP Ostatus_profile::ensureProfileURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ostatus_profile的用法示例。


在下文中一共展示了Ostatus_profile::ensureProfileURL方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: registerInitialUser

 /**
  * Create the initial admin user account.
  * Side effect: may load portions of StatusNet framework.
  * Side effect: outputs program info
  */
 function registerInitialUser()
 {
     define('STATUSNET', true);
     define('LACONICA', true);
     // compatibility
     require_once INSTALLDIR . '/lib/common.php';
     $data = array('nickname' => $this->adminNick, 'password' => $this->adminPass, 'fullname' => $this->adminNick);
     if ($this->adminEmail) {
         $data['email'] = $this->adminEmail;
     }
     $user = User::register($data);
     if (empty($user)) {
         return false;
     }
     // give initial user carte blanche
     $user->grantRole('owner');
     $user->grantRole('moderator');
     $user->grantRole('administrator');
     // Attempt to do a remote subscribe to update@status.net
     // Will fail if instance is on a private network.
     if ($this->adminUpdates && class_exists('Ostatus_profile')) {
         try {
             $oprofile = Ostatus_profile::ensureProfileURL('http://update.status.net/');
             Subscription::start($user->getProfile(), $oprofile->localProfile());
             $this->updateStatus("Set up subscription to <a href='http://update.status.net/'>update@status.net</a>.");
         } catch (Exception $e) {
             $this->updateStatus("Could not set up subscription to <a href='http://update.status.net/'>update@status.net</a>.", true);
         }
     }
     return true;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:36,代码来源:installer.php

示例4: 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

示例5: 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

示例6: profileForFeed

 /**
  *
  * @param string $url
  * @return Profile
  */
 protected function profileForFeed($url)
 {
     try {
         // Maybe we got a web page?
         $oprofile = Ostatus_profile::ensureProfileURL($url);
     } catch (Exception $e) {
         // Direct feed URL?
         $oprofile = Ostatus_profile::ensureFeedURL($url);
     }
     if ($oprofile->isGroup()) {
         // TRANS: Client error displayed when trying to mirror a StatusNet group feed.
         $this->clientError(_m('Cannot mirror a StatusNet group at this time.'));
     }
     $this->oprofile = $oprofile;
     // @todo FIXME: ugly side effect :D
     return $oprofile->localProfile();
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:22,代码来源:basemirror.php

示例7: updateOStatus

function updateOStatus($user)
{
    if (!have_option('q', 'quiet')) {
        echo "{$user->nickname}...";
    }
    $up = $user->getProfile();
    $sp = $user->getSubscriptions();
    $rps = array();
    while ($sp->fetch()) {
        $remote = Remote_profile::staticGet('id', $sp->id);
        if (!empty($remote)) {
            $rps[] = clone $sp;
        }
    }
    if (!have_option('q', 'quiet')) {
        echo count($rps) . "\n";
    }
    foreach ($rps as $rp) {
        try {
            if (!have_option('q', 'quiet')) {
                echo "Checking {$rp->nickname}...";
            }
            $op = Ostatus_profile::ensureProfileURL($rp->profileurl);
            if (empty($op)) {
                echo "can't convert.\n";
                continue;
            } else {
                if (!have_option('q', 'quiet')) {
                    echo "Converting...";
                }
                Subscription::start($up, $op->localProfile());
                Subscription::cancel($up, $rp);
                if (!have_option('q', 'quiet')) {
                    echo "done.\n";
                }
            }
        } catch (Exception $e) {
            if (!have_option('q', 'quiet')) {
                echo "fail.\n";
            }
            common_log(LOG_NOTICE, "Couldn't convert OMB subscription (" . $up->nickname . ", " . $rp->nickname . ") to OStatus: " . $e->getMessage());
            continue;
        }
    }
}
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:45,代码来源:updateostatus.php

示例8: profileForFeed

 /**
  *
  * @param string $url
  * @return Profile
  */
 protected function profileForFeed($url)
 {
     try {
         // Maybe we got a web page?
         $oprofile = Ostatus_profile::ensureProfileURL($url);
     } catch (Exception $e) {
         // Direct feed URL?
         $oprofile = Ostatus_profile::ensureFeedURL($url);
     }
     if ($oprofile->isGroup()) {
         $this->clientError(_m("Can't mirror a StatusNet group at this time."));
     }
     $this->oprofile = $oprofile;
     // @fixme ugly side effect :D
     return $oprofile->localProfile();
 }
开发者ID:Br3nda,项目名称:statusnet-debian,代码行数:21,代码来源:basemirror.php

示例9: onCheckActivityAuthorship

 public static function onCheckActivityAuthorship(Activity $activity, Profile &$profile)
 {
     try {
         $oprofile = Ostatus_profile::ensureProfileURL($profile->getUrl());
         $profile = $oprofile->checkAuthorship($activity);
     } catch (Exception $e) {
         common_log(LOG_ERR, 'Could not get a profile or check authorship (' . get_class($e) . ': "' . $e->getMessage() . '") for activity ID: ' . $activity->id);
         $profile = null;
         return false;
     }
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:12,代码来源:OStatusPlugin.php


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