diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..07f408b --- /dev/null +++ b/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 + +
<?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;
+  }
+}
+?>
+ +

Configuration where fopen can't be accessed from cron

+ +

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:

+ +
deny from all
+<Files cron.php>
+order allow,deny
+allow from all
+</Files>
diff --git a/plugins/db_store.php b/plugins/db_store.php index d2dbb13..16a5bf9 100644 --- a/plugins/db_store.php +++ b/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"; diff --git a/plugins/linkify.php b/plugins/linkify.php index 3c3a61b..7de4af5 100644 --- a/plugins/linkify.php +++ b/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\-]+))/' ); diff --git a/plugins/tweetcc.php b/plugins/tweetcc.php new file mode 100644 index 0000000..d05d8b5 --- /dev/null +++ b/plugins/tweetcc.php @@ -0,0 +1,14 @@ +url . '?username=' . $tweet->from_user)); + + $tweet->tweet_cc = $cc[$tweet->from_user]; + + return $tweet; + } +} + +?> \ No newline at end of file