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


PHP Subscription::staticGet方法代码示例

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


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

示例1: save_notice

 function save_notice(&$req, &$consumer, &$token)
 {
     $version = $req->get_parameter('omb_version');
     if ($version != OMB_VERSION_01) {
         $this->clientError(_('Unsupported OMB version'), 400);
         return false;
     }
     # First, check to see
     $listenee = $req->get_parameter('omb_listenee');
     $remote_profile = Remote_profile::staticGet('uri', $listenee);
     if (!$remote_profile) {
         $this->clientError(_('Profile unknown'), 403);
         return false;
     }
     $sub = Subscription::staticGet('token', $token->key);
     if (!$sub) {
         $this->clientError(_('No such subscription'), 403);
         return false;
     }
     $content = $req->get_parameter('omb_notice_content');
     $content_shortened = common_shorten_links($content);
     if (mb_strlen($content_shortened) > 140) {
         $this->clientError(_('Invalid notice content'), 400);
         return false;
     }
     $notice_uri = $req->get_parameter('omb_notice');
     if (!Validate::uri($notice_uri) && !common_valid_tag($notice_uri)) {
         $this->clientError(_('Invalid notice uri'), 400);
         return false;
     }
     $notice_url = $req->get_parameter('omb_notice_url');
     if ($notice_url && !common_valid_http_url($notice_url)) {
         $this->clientError(_('Invalid notice url'), 400);
         return false;
     }
     $notice = Notice::staticGet('uri', $notice_uri);
     if (!$notice) {
         $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, null, $notice_uri);
         if (is_string($notice)) {
             common_server_serror($notice, 500);
             return false;
         }
         common_broadcast_notice($notice, true);
     }
     return true;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:46,代码来源:postnotice.php

示例2: new_access_token

 function new_access_token($token, $consumer)
 {
     common_debug('new_access_token("' . $token->key . '","' . $consumer->key . '")', __FILE__);
     $rt = new Token();
     $rt->consumer_key = $consumer->key;
     $rt->tok = $token->key;
     $rt->type = 0;
     // request
     if ($rt->find(true) && $rt->state == 1) {
         // authorized
         common_debug('request token found.', __FILE__);
         $at = new Token();
         $at->consumer_key = $consumer->key;
         $at->tok = common_good_rand(16);
         $at->secret = common_good_rand(16);
         $at->type = 1;
         // access
         $at->created = DB_DataObject_Cast::dateTime();
         if (!$at->insert()) {
             $e = $at->_lastError;
             common_debug('access token "' . $at->tok . '" not inserted: "' . $e->message . '"', __FILE__);
             return null;
         } else {
             common_debug('access token "' . $at->tok . '" inserted', __FILE__);
             // burn the old one
             $orig_rt = clone $rt;
             $rt->state = 2;
             // used
             if (!$rt->update($orig_rt)) {
                 return null;
             }
             common_debug('request token "' . $rt->tok . '" updated', __FILE__);
             // Update subscription
             // XXX: mixing levels here
             $sub = Subscription::staticGet('token', $rt->tok);
             if (!$sub) {
                 return null;
             }
             common_debug('subscription for request token found', __FILE__);
             $orig_sub = clone $sub;
             $sub->token = $at->tok;
             $sub->secret = $at->secret;
             if (!$sub->update($orig_sub)) {
                 return null;
             } else {
                 common_debug('subscription updated to use access token', __FILE__);
                 return new OAuthToken($at->tok, $at->secret);
             }
         }
     } else {
         return null;
     }
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:53,代码来源:oauthstore.php

示例3: onEndNoticeAsActivity

 function onEndNoticeAsActivity($notice, &$activity)
 {
     switch ($notice->verb) {
         case ActivityVerb::FAVORITE:
             $fave = Fave::staticGet('uri', $notice->uri);
             if (!empty($fave)) {
                 $notice = Notice::staticGet('id', $fave->notice_id);
                 if (!empty($notice)) {
                     $cur = common_current_user();
                     $target = $notice->asActivity($cur);
                     if ($target->verb == ActivityVerb::POST) {
                         // "I like the thing you posted"
                         $activity->objects = $target->objects;
                     } else {
                         // "I like that you did whatever you did"
                         $activity->objects = array($target);
                     }
                 }
             }
             break;
         case ActivityVerb::UNFAVORITE:
             // FIXME: do something here
             break;
         case ActivityVerb::JOIN:
             $mem = Group_member::staticGet('uri', $notice->uri);
             if (!empty($mem)) {
                 $group = $mem->getGroup();
                 $activity->objects = array(ActivityObject::fromGroup($group));
             }
             break;
         case ActivityVerb::LEAVE:
             // FIXME: ????
             break;
         case ActivityVerb::FOLLOW:
             $sub = Subscription::staticGet('uri', $notice->uri);
             if (!empty($sub)) {
                 $profile = Profile::staticGet('id', $sub->subscribed);
                 if (!empty($profile)) {
                     $activity->objects = array(ActivityObject::fromProfile($profile));
                 }
             }
             break;
         case ActivityVerb::UNFOLLOW:
             // FIXME: ????
             break;
     }
     return true;
 }
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:48,代码来源:ActivityPlugin.php


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