Permalink
Browse files

Merge branch 'master' of git@github.com:remy/tweed

Conflicts:
	plugins/db_store.php
  • Loading branch information...
2 parents 2f5963b + 65c644e commit a43fb66415ee10f73e8063fcc75008c3bdc53555 Remy Sharp committed Sep 23, 2009
Showing with 59 additions and 2 deletions.
  1. +43 −0 README.markdown
  2. +1 −1 plugins/db_store.php
  3. +1 −1 plugins/linkify.php
  4. +14 −0 plugins/tweetcc.php
View
43 README.markdown
@@ -0,0 +1,43 @@
+# Tweed - Twitter Feeder
+
+Tweed reads from a Twitter search URL and pushes each individual tweet through the plugins that have been specified in the config.yaml.
+
+Tweed has been tested with PHP4 and PHP5, but if you spot any issues, ping me on Twitter [@rem](http://twitter.com/rem) and/or post up the full detail on the GitHub issues - or *even* better, go fork and fix it for us! :-)
+
+## Config settings
+
+Check out the boilerplate config for Tweed. Most of the options are pretty self explanatory, and the db\_store plugin will automatically create the database table for you if you use it (so change the schema in there - though this should probably be a config elsewhere).
+
+The key is really the cascading plugins. The order you specify the plugins is the order in which they are used against each tweet.
+
+So if you want to store the tweets, make sure db\_store is the last plugin.
+
+## Plugin design
+
+Drop new plugins in to the plugins directory. They are classes with a constructor (not required) and a `run` method.
+
+For the tweet to cascade to the next plugin, you must return the tweet, otherwise `return false` (although returning nothing will also do the trick).
+
+### Example plugin
+
+<pre><code>&lt;?php
+class dump {
+ // tweet is the full single object that returns from a JSON hit to the search API
+ function run($tweet) {
+ var_dump($tweet);
+
+ // maintains the chain of plugins for this tweet
+ return $tweet;
+ }
+}
+?&gt;</code></pre>
+
+<h2>Configuration where fopen can't be accessed from cron</h2>
+
+<p>You need to set up a cronjob that does a URL hit rather than running from the command line. You should still protect the directory from reading via the .htaccess file, but you'll need to allow entry to the cron.php file:</p>
+
+<pre><code>deny from all
+&lt;Files cron.php&gt;
+order allow,deny
+allow from all
+&lt;/Files&gt;</code></pre>
View
2 plugins/db_store.php
@@ -59,7 +59,7 @@ function deconstructor() {
function run($tweet) {
if (($this->initialised && $this->connected) || $this->config['debug']) {
- $sql = sprintf('insert into ' . $this->table . ' (id, avatar, name, screen_name, message, createdDate) values (%d, "%s", "%s", "%s", "%s", "%s")', $tweet->id, mysql_escape_string($tweet->profile_image_url), mysql_escape_string($tweet->from_user), mysql_escape_string($tweet->from_user), mysql_escape_string($tweet->text), date('c', $tweet->created_at));
+ $sql = sprintf('insert into ' . $this->table . ' (id, avatar, name, screen_name, message, createdDate) values (' . $tweet->id . ', "%s", "%s", "%s", "%s", "%s")', mysql_escape_string($tweet->profile_image_url), mysql_escape_string($tweet->from_user), mysql_escape_string($tweet->from_user), mysql_escape_string($tweet->text), date('c', $tweet->created_at));
if ($this->config['debug']) {
echo $sql . ";\n";
View
2 plugins/linkify.php
@@ -5,7 +5,7 @@ class linkify {
function linkify() {
// note - this order is important, i.e. links at the top, then anything else
$this->matches = array(
- '(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/)',
+ '/([A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+)/',
'/(^|[^\w])(#[\d\w\-]+)/',
'/(^|[^\w])(@([\d\w\-]+))/'
);
View
14 plugins/tweetcc.php
@@ -0,0 +1,14 @@
+<?php
+class tweetcc {
+ var $url = 'http://tweetcc.com/api/tweetcc.json.php';
+
+ function run($tweet) {
+ $cc = json_decode(file_get_contents($this->url . '?username=' . $tweet->from_user));
+
+ $tweet->tweet_cc = $cc[$tweet->from_user];
+
+ return $tweet;
+ }
+}
+
+?>

0 comments on commit a43fb66

Please sign in to comment.