BusyBird::Filter::Twitter - filters for statuses imported from Twitter
use BusyBird; use BusyBird::Filter::Twitter qw(:all); use BusyBird::Filter qw(filter_each); timeline("home")->add_filter(filter_twitter_all); ## or alternatively, timeline("home")->add_filter(filter_each sub { my ($status) = @_; trans_twitter_all($status); });
This module provides transformations and filters that you should apply to statuses imported from Twitter. Basically it does the following transformation to the input statuses.
Convert status IDs to include the source of the statuses. This prevents ID conflict between statuses from different sources.
Add BusyBird-specific fields to the statuses.
Normalize status objects from Search API v1.0.
HTML-unescape text content so that BusyBird can render it appropriately.
Note that this module does not help you import statuses from Twitter. For that purpose, I recommend Net::Twitter::Loader.
By default, this module exports nothing. You can import the following functions individually and/or by tags. Import ":all" to import all functions at once.
":all"
These functions transform a single status object and return the result. The transformation is destructive.
Applies all transformations described below to the given $status.
$status
Argument $api_url is optional. See trans_twitter_status_id() function below.
$api_url
trans_twitter_status_id()
Transforms the $status returned by Twitter's Search API v1.0 into something more like a normal status object.
Transforms the $status's ID fields so that they include API URL of the source. This transformation is recommended when you load statuses from multiple sources, e.g. twitter.com and loadaverage.org.
Argument $api_url is optional. By default it is "https://api.twitter.com/1.1/". You should set it appropriately if you import statuses from other sites.
"https://api.twitter.com/1.1/"
The original IDs are saved under $status->{busybird}{original}
$status->{busybird}{original}
Unescapes some HTML entities in the $status's text field.
HTML-unescape is necessary because twitter.com automatically HTML-escapes some special characters, AND BusyBird also HTML-escapes status texts when it renders them. This results in double HTML-escapes.
The transformation changes the status's text length. "indices" fields in the status's Twitter Entities are adjusted appropriately.
"indices"
The transformation is applied recursively to the status's retweeted_status, if any.
retweeted_status
These functions generate a synchronous status filter corresponding to the trans_twitter_* functions.
trans_twitter_*
All filters are non-destructive. That is, they won't modify input statuses. Transformation is done to their clones.
BusyBird::Filter
Net::Twitter
Net::Twitter::Lite
Net::Twitter::Loader
Toshio Ito <toshioito [at] cpan.org>
<toshioito [at] cpan.org>
To install BusyBird, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BusyBird
CPAN shell
perl -MCPAN -e shell install BusyBird
For more information on module installation, please visit the detailed CPAN module installation guide.