Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions system/expressionengine/third_party/twitter/mod.twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,39 @@ public function search()
return $this->render_tweets($statuses, $prefix, $userprefix);
}

public function getbyid()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be better as {exp:twitter:tweet id="..."} or {exp:twitter:single_tweet id="..."}? {exp:twitter:getbyid} doesn't seem to have much flow to it. What am I getting by ID?

{
// Fetch parameters
$this->refresh = $this->EE->TMPL->fetch_param('twitter_refresh', $this->refresh);
$this->limit = $this->EE->TMPL->fetch_param('limit', '1');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need limit to be a parameter anymore. Lets just remove this parameter, and hardcode $this->limit = 1 instead. I'm not even sure that's necessary, since Twitter will always return at most 1 tweet for an ID, but it's probably good self-documentation.

$this->use_stale = $this->EE->TMPL->fetch_param('use_stale_cache', 'yes');
$this->target = $this->EE->TMPL->fetch_param('target', '');
$query = $this->EE->TMPL->fetch_param('id');
$prefix = $this->EE->TMPL->fetch_param('prefix', '');
$userprefix = $this->EE->TMPL->fetch_param('userprefix', NULL);

if (!$query)
{
$this->EE->TMPL->log_item("Parameter query was not provided");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Parameter id was not provided."

return;
}

// timeline type
$timeline = 'getbyid';
$log_extra = "Get by id:{$query}";

$this->EE->TMPL->log_item("Using '{$timeline}' Twitter Timeline {$log_extra}");

$url = "statuses/show";
$params = array('id' => $query);

// retrieve statuses
$statuses = $this->_fetch_data($url, $params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well now I'm just getting picky, so you can ignore this one. But maybe this is better written:

$status = $this->_fetch_data($url, $params);
$statuses = array($status);

$statuses = array($statuses);

return $this->render_tweets($statuses, $prefix, $userprefix);
}

public function get_list()
{
// Fetch parameters
Expand Down