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


PHP Ostatus_profile类代码示例

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


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

示例1: handle

 function handle($notice)
 {
     assert($notice instanceof Notice);
     $this->notice = $notice;
     $this->user = User::staticGet($notice->profile_id);
     $this->pushUser();
     foreach ($notice->getGroups() as $group) {
         $oprofile = Ostatus_profile::staticGet('group_id', $group->id);
         if ($oprofile) {
             $this->pingReply($oprofile);
         } else {
             $this->pushGroup($group->id);
         }
     }
     foreach ($notice->getReplies() as $profile_id) {
         $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
         if ($oprofile) {
             $this->pingReply($oprofile);
         }
     }
     if (!empty($this->notice->reply_to)) {
         $replyTo = Notice::staticGet('id', $this->notice->reply_to);
         if (!empty($replyTo)) {
             foreach ($replyTo->getReplies() as $profile_id) {
                 $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
                 if ($oprofile) {
                     $this->pingReply($oprofile);
                 }
             }
         }
     }
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:33,代码来源:ostatusqueuehandler.php

示例2: onStartHandleFeedEntry

 function onStartHandleFeedEntry($activity)
 {
     common_log(LOG_INFO, 'photo plugin: onEndAtomPubNewActivity');
     $oprofile = Ostatus_profile::ensureActorProfile($activity);
     foreach ($activity->objects as $object) {
         if ($object->type == ActivityObject::PHOTO) {
             $uri = $object->largerImage;
             $thumb_uri = $object->thumbnail;
             $profile_id = $oprofile->profile_id;
             $source = 'unknown';
             // TODO: put something better here.
             common_log(LOG_INFO, 'uri : ' . $uri);
             common_log(LOG_INFO, 'thumb_uri : ' . $thumb_uri);
             // It's possible this is validated elsewhere, but I'm not sure and
             // would rather be safe.
             $uri = filter_var($uri, FILTER_SANITIZE_URL);
             $thumb_uri = filter_var($thumb_uri, FILTER_SANITIZE_URL);
             $uri = filter_var($uri, FILTER_VALIDATE_URL);
             $thumb_uri = filter_var($thumb_uri, FILTER_VALIDATE_URL);
             if (empty($thumb_uri)) {
                 // We need a thumbnail, so if we aren't given one, use the actual picture for now.
                 $thumb_uri = $uri;
             }
             if (!empty($uri) && !empty($thumb_uri)) {
                 GNUsocialPhoto::saveNew($profile_id, $thumb_uri, $uri, $source, false);
             } else {
                 common_log(LOG_INFO, 'bad URI for photo');
             }
             return false;
         }
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:33,代码来源:GNUsocialPhotosPlugin.php

示例3: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $id = $this->trimmed('id');
     if (!$id) {
         $this->clientError(_('No ID.'));
     }
     $this->group = User_group::staticGet('id', $id);
     if (empty($this->group)) {
         $this->clientError(_('No such group.'));
     }
     $oprofile = Ostatus_profile::staticGet('group_id', $id);
     if ($oprofile) {
         $this->clientError(_m("Can't accept remote posts for a remote group."));
     }
     return true;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:17,代码来源:groupsalmon.php

示例4: handle

 function handle($notice)
 {
     assert($notice instanceof Notice);
     $this->notice = $notice;
     $this->user = User::staticGet('id', $notice->profile_id);
     try {
         $profile = $this->notice->getProfile();
     } catch (Exception $e) {
         common_log(LOG_ERR, "Can't get profile for notice; skipping: " . $e->getMessage());
         return true;
     }
     $this->pushUser();
     foreach ($notice->getGroups() as $group) {
         $oprofile = Ostatus_profile::staticGet('group_id', $group->id);
         if ($oprofile) {
             $this->pingReply($oprofile);
         } else {
             $this->pushGroup($group->id);
         }
     }
     foreach ($notice->getReplies() as $profile_id) {
         $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
         if ($oprofile) {
             $this->pingReply($oprofile);
         }
     }
     if (!empty($this->notice->reply_to)) {
         $replyTo = Notice::staticGet('id', $this->notice->reply_to);
         if (!empty($replyTo)) {
             foreach ($replyTo->getReplies() as $profile_id) {
                 $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id);
                 if ($oprofile) {
                     $this->pingReply($oprofile);
                 }
             }
         }
     }
     foreach ($notice->getProfileTags() as $ptag) {
         $oprofile = Ostatus_profile::staticGet('peopletag_id', $ptag->id);
         if (!$oprofile) {
             $this->pushPeopletag($ptag);
         }
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:45,代码来源:ostatusqueuehandler.php

示例5: prepare

 function prepare($args)
 {
     parent::prepare($args);
     $id = $this->trimmed('id');
     if (!$id) {
         // TRANS: Client error displayed trying to perform an action without providing an ID.
         $this->clientError(_m('No ID.'));
     }
     $this->peopletag = Profile_list::staticGet('id', $id);
     if (empty($this->peopletag)) {
         // TRANS: Client error displayed when referring to a non-existing list.
         $this->clientError(_m('No such list.'));
     }
     $oprofile = Ostatus_profile::staticGet('peopletag_id', $id);
     if (!empty($oprofile)) {
         // TRANS: Client error displayed when trying to send a message to a remote list.
         $this->clientError(_m('Cannot accept remote posts for a remote list.'));
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:20,代码来源:peopletagsalmon.php

示例6: prepare

 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $id = $this->trimmed('id');
     if (!$id) {
         // TRANS: Client error.
         $this->clientError(_m('No ID.'));
     }
     $this->group = User_group::getKV('id', $id);
     if (!$this->group instanceof User_group) {
         // TRANS: Client error.
         $this->clientError(_m('No such group.'));
     }
     $this->target = $this->group;
     $remote_group = Ostatus_profile::getKV('group_id', $id);
     if ($remote_group instanceof Ostatus_profile) {
         // TRANS: Client error.
         $this->clientError(_m('Cannot accept remote posts for a remote group.'));
     }
     return true;
 }
开发者ID:phpsource,项目名称:gnu-social,代码行数:21,代码来源:groupsalmon.php

示例7: prepare

 protected function prepare(array $args = array())
 {
     parent::prepare($args);
     $id = $this->trimmed('id');
     if (!$id) {
         // TRANS: Client error displayed trying to perform an action without providing an ID.
         $this->clientError(_m('No ID.'));
     }
     $this->peopletag = Profile_list::getKV('id', $id);
     if (!$this->peopletag instanceof Profile_list) {
         // TRANS: Client error displayed when referring to a non-existing list.
         $this->clientError(_m('No such list.'));
     }
     $this->target = $this->peopletag;
     $remote_list = Ostatus_profile::getKV('peopletag_id', $id);
     if ($remote_list instanceof Ostatus_profile) {
         // TRANS: Client error displayed when trying to send a message to a remote list.
         $this->clientError(_m('Cannot accept remote posts for a remote list.'));
     }
     return true;
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:21,代码来源:peopletagsalmon.php

示例8: fixProfile

function fixProfile($uri)
{
    $oprofile = Ostatus_profile::getKV('uri', $uri);
    if (!$oprofile) {
        print "No OStatus remote profile known for URI {$uri}\n";
        return false;
    }
    echo "Before:\n";
    showProfileInfo($oprofile);
    $feedurl = $oprofile->feeduri;
    $client = new HttpClient();
    $response = $client->get($feedurl);
    if ($response->isOk()) {
        echo "Updating profile from feed: {$feedurl}\n";
        $dom = new DOMDocument();
        if ($dom->loadXML($response->getBody())) {
            $feed = $dom->documentElement;
            $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry');
            if ($entries->length) {
                $entry = $entries->item(0);
                $activity = new Activity($entry, $feed);
                $oprofile->checkAuthorship($activity);
                echo "  (ok)\n";
            } else {
                echo "  (no entry; skipping)\n";
                return false;
            }
        } else {
            echo "  (bad feed; skipping)\n";
            return false;
        }
    } else {
        echo "Failed feed fetch: {$response->getStatus()} for {$feedurl}\n";
        return false;
    }
    echo "After:\n";
    showProfileInfo($oprofile);
    return true;
}
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:39,代码来源:update-profile-data.php

示例9: handle

 function handle($object)
 {
     list($user, $remote, $password) = $object;
     $remote = Discovery::normalize($remote);
     $oprofile = Ostatus_profile::ensureProfileURI($remote);
     if (empty($oprofile)) {
         // TRANS: Exception thrown when an account could not be located when it should be moved.
         // TRANS: %s is the remote site.
         throw new Exception(sprintf(_("Cannot locate account %s."), $remote));
     }
     list($svcDocUrl, $username) = self::getServiceDocument($remote);
     $sink = new ActivitySink($svcDocUrl, $username, $password);
     $this->log(LOG_INFO, "Moving user {$user->nickname} " . "to {$remote}.");
     $stream = new UserActivityStream($user);
     // Reverse activities to run in correct chron order
     $acts = array_reverse($stream->activities);
     $this->log(LOG_INFO, "Got " . count($acts) . " activities " . "for {$user->nickname}.");
     $qm = QueueManager::get();
     foreach ($acts as $act) {
         $qm->enqueue(array($act, $sink, $user->uri, $remote), 'actmove');
     }
     $this->log(LOG_INFO, "Finished moving user {$user->nickname} " . "to {$remote}.");
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:23,代码来源:accountmover.php

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

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

示例12: getFeed

 private function getFeed($profile)
 {
     // Ok this is a bit of a hack. ;)
     if (class_exists('Ostatus_profile')) {
         $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
         if ($oprofile) {
             return $oprofile->feeduri;
         }
     }
     var_dump('wtf');
     return false;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:12,代码来源:editmirrorform.php

示例13: onStartGetProfileFromURI

 function onStartGetProfileFromURI($uri, &$profile)
 {
     // Don't want to do Web-based discovery on our own server,
     // so we check locally first.
     $user = User::staticGet('uri', $uri);
     if (!empty($user)) {
         $profile = $user->getProfile();
         return false;
     }
     // Now, check remotely
     $oprofile = Ostatus_profile::ensureProfileURI($uri);
     if (!empty($oprofile)) {
         $profile = $oprofile->localProfile();
         return false;
     }
     // Still not a hit, so give up.
     return true;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:18,代码来源:OStatusPlugin.php

示例14: onEndBroadcastProfile

 /**
  * Ping remote profiles with updates to this profile.
  * Salmon pings are queued for background processing.
  */
 function onEndBroadcastProfile(Profile $profile)
 {
     $user = User::staticGet('id', $profile->id);
     // Find foreign accounts I'm subscribed to that support Salmon pings.
     //
     // @fixme we could run updates through the PuSH feed too,
     // in which case we can skip Salmon pings to folks who
     // are also subscribed to me.
     $sql = "SELECT * FROM ostatus_profile " . "WHERE profile_id IN " . "(SELECT subscribed FROM subscription WHERE subscriber=%d) " . "OR group_id IN " . "(SELECT group_id FROM group_member WHERE profile_id=%d)";
     $oprofile = new Ostatus_profile();
     $oprofile->query(sprintf($sql, $profile->id, $profile->id));
     if ($oprofile->N == 0) {
         common_log(LOG_DEBUG, "No OStatus remote subscribees for {$profile->nickname}");
         return true;
     }
     $act = new Activity();
     $act->verb = ActivityVerb::UPDATE_PROFILE;
     $act->id = TagURI::mint('update-profile:%d:%s', $profile->id, common_date_iso8601(time()));
     $act->time = time();
     $act->title = _m("Profile update");
     $act->content = sprintf(_m("%s has updated their profile page."), $profile->getBestName());
     $act->actor = ActivityObject::fromProfile($profile);
     $act->object = $act->actor;
     while ($oprofile->fetch()) {
         $oprofile->notifyDeferred($act, $profile);
     }
     return true;
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:32,代码来源:OStatusPlugin.php

示例15: ensureWebfinger

 /**
  * Look up, and if necessary create, an Ostatus_profile for the remote
  * entity with the given webfinger address.
  * This should never return null -- you will either get an object or
  * an exception will be thrown.
  *
  * @param string $addr webfinger address
  * @return Ostatus_profile
  * @throws Exception on error conditions
  * @throws OStatusShadowException if this reference would obscure a local user/group
  */
 public static function ensureWebfinger($addr)
 {
     // First, try the cache
     $uri = self::cacheGet(sprintf('ostatus_profile:webfinger:%s', $addr));
     if ($uri !== false) {
         if (is_null($uri)) {
             // Negative cache entry
             throw new Exception('Not a valid webfinger address.');
         }
         $oprofile = Ostatus_profile::staticGet('uri', $uri);
         if (!empty($oprofile)) {
             return $oprofile;
         }
     }
     // Try looking it up
     $oprofile = Ostatus_profile::staticGet('uri', 'acct:' . $addr);
     if (!empty($oprofile)) {
         self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
         return $oprofile;
     }
     // Now, try some discovery
     $disco = new Discovery();
     try {
         $xrd = $disco->lookup($addr);
     } catch (Exception $e) {
         // Save negative cache entry so we don't waste time looking it up again.
         // @fixme distinguish temporary failures?
         self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), null);
         throw new Exception('Not a valid webfinger address.');
     }
     $hints = array('webfinger' => $addr);
     $dhints = DiscoveryHints::fromXRD($xrd);
     $hints = array_merge($hints, $dhints);
     // If there's an Hcard, let's grab its info
     if (array_key_exists('hcard', $hints)) {
         if (!array_key_exists('profileurl', $hints) || $hints['hcard'] != $hints['profileurl']) {
             $hcardHints = DiscoveryHints::fromHcardUrl($hints['hcard']);
             $hints = array_merge($hcardHints, $hints);
         }
     }
     // If we got a feed URL, try that
     if (array_key_exists('feedurl', $hints)) {
         try {
             common_log(LOG_INFO, "Discovery on acct:{$addr} with feed URL " . $hints['feedurl']);
             $oprofile = self::ensureFeedURL($hints['feedurl'], $hints);
             self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
             return $oprofile;
         } catch (Exception $e) {
             common_log(LOG_WARNING, "Failed creating profile from feed URL '{$feedUrl}': " . $e->getMessage());
             // keep looking
         }
     }
     // If we got a profile page, try that!
     if (array_key_exists('profileurl', $hints)) {
         try {
             common_log(LOG_INFO, "Discovery on acct:{$addr} with profile URL {$profileUrl}");
             $oprofile = self::ensureProfileURL($hints['profileurl'], $hints);
             self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->uri);
             return $oprofile;
         } catch (OStatusShadowException $e) {
             // We've ended up with a remote reference to a local user or group.
             // @fixme ideally we should be able to say who it was so we can
             // go back and refer to it the regular way
             throw $e;
         } catch (Exception $e) {
             common_log(LOG_WARNING, "Failed creating profile from profile URL '{$profileUrl}': " . $e->getMessage());
             // keep looking
             //
             // @fixme this means an error discovering from profile page
             // may give us a corrupt entry using the webfinger URI, which
             // will obscure the correct page-keyed profile later on.
         }
     }
     // XXX: try hcard
     // XXX: try FOAF
     if (array_key_exists('salmon', $hints)) {
         $salmonEndpoint = $hints['salmon'];
         // An account URL, a salmon endpoint, and a dream? Not much to go
         // on, but let's give it a try
         $uri = 'acct:' . $addr;
         $profile = new Profile();
         $profile->nickname = self::nicknameFromUri($uri);
         $profile->created = common_sql_now();
         if (isset($profileUrl)) {
             $profile->profileurl = $profileUrl;
         }
         $profile_id = $profile->insert();
         if (!$profile_id) {
             common_log_db_error($profile, 'INSERT', __FILE__);
//.........这里部分代码省略.........
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:101,代码来源:Ostatus_profile.php


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