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


PHP Foreign_link::update方法代码示例

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


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

示例1: getTimeline

 function getTimeline(Foreign_link $flink, $timelineUri = 'home_timeline')
 {
     common_log(LOG_DEBUG, $this->name() . ' - Trying to get ' . $timelineUri . ' timeline for Twitter user ' . $flink->foreign_id);
     $client = null;
     if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
         $token = TwitterOAuthClient::unpackToken($flink->credentials);
         $client = new TwitterOAuthClient($token->key, $token->secret);
         common_log(LOG_DEBUG, $this->name() . ' - Grabbing ' . $timelineUri . ' timeline with OAuth.');
     } else {
         common_log(LOG_ERR, "Skipping " . $timelineUri . " timeline for " . $flink->foreign_id . " since not OAuth.");
     }
     $timeline = null;
     $lastId = Twitter_synch_status::getLastId($flink->foreign_id, $timelineUri);
     common_log(LOG_DEBUG, "Got lastId value '" . $lastId . "' for foreign id '" . $flink->foreign_id . "' and timeline '" . $timelineUri . "'");
     try {
         $timeline = $client->statusesTimeline($lastId, $timelineUri);
     } catch (Exception $e) {
         common_log(LOG_ERR, $this->name() . ' - Unable to get ' . $timelineUri . ' timeline for user ' . $flink->user_id . ' - code: ' . $e->getCode() . 'msg: ' . $e->getMessage());
     }
     if (empty($timeline)) {
         common_log(LOG_DEBUG, $this->name() . " - Empty '" . $timelineUri . "' timeline.");
         return;
     }
     common_log(LOG_INFO, $this->name() . ' - Retrieved ' . sizeof($timeline) . ' statuses from ' . $timelineUri . ' timeline' . ' - for user ' . $flink->user_id);
     if (!empty($timeline)) {
         $qm = QueueManager::get();
         // Reverse to preserve order
         foreach (array_reverse($timeline) as $status) {
             $data = array('status' => $status, 'for_user' => $flink->foreign_id);
             $qm->enqueue($data, 'tweetin');
         }
         $lastId = twitter_id($timeline[0]);
         Twitter_synch_status::setLastId($flink->foreign_id, $timelineUri, $lastId);
         common_debug("Set lastId value '{$lastId}' for foreign id '{$flink->foreign_id}' and timeline '" . $timelineUri . "'");
     }
     // Okay, record the time we synced with Twitter for posterity
     $flink->last_noticesync = common_sql_now();
     $flink->update();
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:39,代码来源:twitterstatusfetcher.php


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