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


PHP Tweet::save方法代码示例

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


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

示例1: process_data

 private function process_data($data)
 {
     foreach ($data->results as $tweet) {
         $tweet = new Tweet($tweet->id_str);
         $tweet->save();
         $this->tids[] = $tweet->tid;
     }
 }
开发者ID:nodefortytwo,项目名称:freshlytics,代码行数:8,代码来源:twitter_rest_query.php

示例2: store

 public function store(Request $request)
 {
     $type = $request->get('type');
     $tweet = Tweet::find($id);
     if (!$tweet) {
         $tweet = new Tweet();
         $tweet[$type] = 1;
     }
     $tweet->id = $request->get('id');
     $tweet->text = $request->get('text');
     $tweet->increment($type);
     $tweet->save();
     return $request->all();
 }
开发者ID:Niiwill,项目名称:pizzaApp,代码行数:14,代码来源:AdminController.php

示例3: create

 public function create()
 {
     $tweet = new Tweet();
     $fromAccount = false;
     if ($this->GetData('account_id')) {
         $account = TwitterAccount::find_by_id($this->GetData('account_id'));
         if ($account) {
             $fromAccount = true;
             $tweet->twitter_account_id = $account->id;
             $tweet->account = $account;
         }
     }
     if ($this->post) {
         $tweet->message = $this->PostData('message');
         $tweet->set_publish_at($this->PostData('publish_at'));
         if ($this->PostData('twitter_account_id')) {
             $tweet->twitter_account_id = $this->PostData('twitter_account_id');
         }
         if ($tweet->save()) {
             Site::Flash('notice', 'Your tweet has been added');
             if ($fromAccount) {
                 Redirect("admin/twitter/accounts/{$account->id}/");
             } else {
                 Redirect("admin/twitter/tweets");
             }
         }
     }
     if ($fromAccount) {
         $this->assign('account', $account);
     } else {
         $accounts = array();
         $allAccounts = TwitterAccount::find_all();
         foreach ($allAccounts as $account) {
             $accounts[$account->id] = $account->name;
         }
         $this->assign('accounts', $accounts);
     }
     $this->assign("tweet", $tweet);
     $this->assign("fromAccount", $fromAccount);
     $this->title = "Add Tweet";
     $this->render("tweet/create.tpl");
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:42,代码来源:tweet.controller.php

示例4: add_tweet

 public function add_tweet($message, $publish_at = null)
 {
     if (!$publish_at) {
         $publish_at = time();
     }
     $tweet = new Tweet();
     $tweet->twitter_account_id = $this->id;
     $tweet->message = $message;
     $tweet->publish_at = $publish_at;
     $tweet->save();
     return $tweet;
 }
开发者ID:ItsHaden,项目名称:epicLanBootstrap,代码行数:12,代码来源:twitter_account.model.php

示例5: execute

 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     $web = new sfWebBrowser();
     $this->logSection($this->namespace, 'Getting latest tweets for @' . sfConfig::get('app_twitter_username'));
     $atom = $web->get('http://search.twitter.com/search.atom?q=from:' . sfConfig::get('app_twitter_username') . '&rpp=5');
     try {
         if (!$atom->responseIsError()) {
             $feed = new SimpleXMLElement($atom->getResponseText());
             foreach ($feed->entry as $rss) {
                 $id = preg_replace('/[^0-9]+/', '', $rss->link[0]['href']);
                 $tweet = Doctrine::getTable('Tweet')->find($id);
                 $namespaces = $rss->getNameSpaces(true);
                 if ($tweet instanceof Tweet) {
                     if (strtotime($rss->updated) <= strtotime($tweet->getUpdatedAt())) {
                         continue;
                     } else {
                         $this->updated++;
                     }
                 } else {
                     $tweet = new Tweet();
                     $this->new++;
                 }
                 $file = $web->get('http://api.twitter.com/1/statuses/show/' . $id . '.json');
                 try {
                     if (!$file->responseIsError()) {
                         $json = json_decode($file->getResponseText());
                         $tweet->setId($id);
                         $tweet->setText($rss->title);
                         $tweet->setHTML(html_entity_decode($rss->content));
                         $tweet->setUri($rss->link[0]['href']);
                         if (isset($json->in_reply_to_status_id)) {
                             $tweet->setReplyId($json->in_reply_to_status_id);
                         }
                         if (isset($json->in_reply_to_user_id)) {
                             $tweet->setReplyUserId($json->in_reply_to_user_id);
                             $tweet->setReplyUsername($json->in_reply_to_screen_name);
                         }
                         if (isset($json->geo, $json->geo->coordinates)) {
                             $tweet->setLatitude($json->geo->coordinates[0]);
                             $tweet->setLongitude($json->geo->coordinates[1]);
                         }
                         $tweet->setLanguage($rss->children($namespaces['twitter'])->lang);
                         $tweet->setSource(html_entity_decode($rss->children($namespaces['twitter'])->source));
                         $tweet->setCreatedAt($rss->published);
                         $tweet->setUpdatedAt($rss->updated);
                         $tweet->save();
                         echo '.';
                     } else {
                         // Error response (eg. 404, 500, etc)
                     }
                 } catch (Exception $e) {
                     // Adapter error (eg. Host not found)
                 }
             }
         } else {
             // Error response (eg. 404, 500, etc)
         }
     } catch (Exception $e) {
         // Adapter error (eg. Host not found)
     }
     echo "\n";
     $this->logSection($this->namespace, 'Done: ' . $this->new . ' new, ' . $this->updated . ' updated.');
 }
开发者ID:benlumley,项目名称:followben,代码行数:65,代码来源:getTweetsTask.class.php


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