本文整理汇总了PHP中Tweet::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Tweet::setId方法的具体用法?PHP Tweet::setId怎么用?PHP Tweet::setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tweet
的用法示例。
在下文中一共展示了Tweet::setId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseTimeline
public function parseTimeline($timeline)
{
foreach ($timeline as $tweet) {
$item = new Tweet();
$item->setId($tweet->id)->setTitle($tweet->text)->setDescription($tweet->text)->setPubDate($tweet->created_at)->setPlace($tweet->place)->setUsername($tweet->user->screen_name)->setUserId($tweet->user->id);
$this->addTweet($item);
}
}
示例2: load
public function load($id) {
$result=HypertableConnection::query("SELECT * FROM tweet ".
"WHERE ROW='$id'");
if (!$result or !count($result->cells))
return null;
$tweet=new Tweet();
$tweet->setId($id);
$tweet->setTimestamp($result->cells[0]->key->timestamp);
$tweet->setMessage($result->cells[0]->value);
return $tweet;
}
示例3: loadTweets
public function loadTweets()
{
$conn = $this->connection;
$sqlQuery = "SELECT user_id, tweets.id, text FROM tweets INNER JOIN users ON tweets.user_id = users.id ORDER BY tweets.created_at DESC";
$result = $conn->query($sqlQuery);
if ($result->num_rows > 0) {
while (list($userId, $tweetId, $text) = $result->fetch_array(MYSQLI_NUM)) {
$tweet = new Tweet($conn);
$tweet->setUserId($userId);
$tweet->setText($text);
$tweet->setId($tweetId);
$this->arrayWithTweets[] = $tweet;
}
return true;
} else {
return false;
}
}
示例4: 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.');
}
示例5: loadAllTweets
public function loadAllTweets()
{
$conn = $this->connection;
$arrayWithTweets = [];
$sqlQuery = "SELECT id, text FROM tweets WHERE user_id = {$this->id} ORDER BY tweets.created_at DESC";
$result = $conn->query($sqlQuery);
if ($result->num_rows > 0) {
while (list($id, $text) = $result->fetch_array(MYSQLI_NUM)) {
$tweet = new Tweet($conn);
$tweet->setId($id);
$tweet->setText($text);
$arrayWithTweets[] = $tweet;
}
return $arrayWithTweets;
}
}