diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-02 13:59:37 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-02 13:59:37 +0200 |
commit | ea87d8d09697388cef5ddba3ba8df76bf4374cdd (patch) | |
tree | cc2d4330e16398afea3008b434d5f09dfbb46f7a | |
parent | 76fd21bccd1b87916f149a257e07d02f5e40335a (diff) |
add comment for twitter fetcher
-rw-r--r-- | dependencyinjection/dicontainer.php | 2 | ||||
-rw-r--r-- | utility/twitterfetcher.php | 15 |
2 files changed, 15 insertions, 2 deletions
diff --git a/dependencyinjection/dicontainer.php b/dependencyinjection/dicontainer.php index 4c6dbae06..7a172a73a 100644 --- a/dependencyinjection/dicontainer.php +++ b/dependencyinjection/dicontainer.php @@ -133,7 +133,7 @@ class DIContainer extends BaseContainer { // register fetchers in order // the most generic fetcher should be the last one - $fetcher->registerFetcher($c['TwitterFetcher']); + $fetcher->registerFetcher($c['TwitterFetcher']); // twitter timeline $fetcher->registerFetcher($c['FeedFetcher']); return $fetcher; diff --git a/utility/twitterfetcher.php b/utility/twitterfetcher.php index 0d1d6738b..7e09ddcb9 100644 --- a/utility/twitterfetcher.php +++ b/utility/twitterfetcher.php @@ -32,9 +32,17 @@ class TwitterFetcher implements IFeedFetcher { private $fetcher; private $regex; - // FIXME: implement twitter api to be future proof + public function __construct(FeedFetcher $fetcher){ $this->fetcher = $fetcher; + + // matches the following urls and extracts the username + // https://twitter.com/GeorgeTakei + // https://www.twitter.com/GeorgeTakei + // http://twitter.com/GeorgeTakei + // http://www.twitter.com/GeorgeTakei + // www.twitter.com/GeorgeTakei + // twitter.com/GeorgeTakei $this->regex = '/^(?:https?:\/\/)?(?:www\.)?' . 'twitter.com\/([\pL\pN\pM]+)$/u'; } @@ -47,8 +55,13 @@ class TwitterFetcher implements IFeedFetcher { public function fetch($url){ preg_match($this->regex, $url, $match); + + // FIXME: implement twitter api to be future proof + // deprecated Twitter RSS API $rssUrl = 'https://api.twitter.com/1/statuses/user_timeline.' . 'rss?screen_name=' . $match[1]; + + // use transformed url to fetch the rss feeds with the default fetcher return $this->fetcher->fetch($rssUrl); } |