Difference between revisions of "MM-Tweeter"

From MidsouthMakers - Memphis Area Hackerpace
Jump to navigation Jump to search
Line 24: Line 24:
 
* Pending Table
 
* Pending Table
 
<pre>
 
<pre>
CREATE TABLE `mmtweeter`.`pending` (
+
CREATE TABLE IF NOT EXISTS `pending` (
`id` INT( 6 ) NOT NULL AUTO_INCREMENT ,
+
  `id` int(6) NOT NULL AUTO_INCREMENT,
`content` VARCHAR( 160 ) NOT NULL ,
+
  `content` varchar(160) NOT NULL,
`post_date` datetime NOT NULL ,
+
  `post_date` datetime NOT NULL,
`added` TIMESTAMP NOT NULL ,
+
  `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`source` VARCHAR( 255 ) NOT NULL ,
+
  `source` varchar(255) NOT NULL,
PRIMARY KEY ( `id` )
+
  PRIMARY KEY (`id`)
) ENGINE = MYISAM ;
+
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
 
</pre>
 
</pre>
 
* History Table
 
* History Table
 
<pre>
 
<pre>
CREATE TABLE `mmtweeter`.`history` (
+
CREATE TABLE IF NOT EXISTS `history` (
`id` INT( 6 ) NOT NULL AUTO_INCREMENT ,
+
  `id` int(6) NOT NULL AUTO_INCREMENT,
`content` VARCHAR( 160 ) NOT NULL ,
+
  `content` varchar(160) NOT NULL,
`post_date` datetime NOT NULL ,
+
  `post_date` date NOT NULL,
`added` TIMESTAMP NOT NULL ,
+
  `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`source` VARCHAR( 255 ) NOT NULL ,
+
  `source` varchar(255) NOT NULL,
`response_code` INT( 4 ) NOT NULL ,
+
  `response_code` int(4) NOT NULL,
PRIMARY KEY ( `id` )
+
  PRIMARY KEY (`id`)
) ENGINE = MYISAM
+
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;
 
</pre>
 
</pre>
 
* Secrets Table
 
* Secrets Table
 
<pre>
 
<pre>
CREATE TABLE `mmtweeter`.`secrets` (
+
CREATE TABLE IF NOT EXISTS `secrets` (
`id` INT NOT NULL AUTO_INCREMENT ,
+
  `id` int(11) NOT NULL AUTO_INCREMENT,
`source` VARCHAR( 255 ) NOT NULL ,
+
  `source` varchar(255) NOT NULL,
`secret` VARCHAR( 255 ) NOT NULL ,
+
  `secret` varchar(255) NOT NULL,
PRIMARY KEY ( `id` )
+
  PRIMARY KEY (`id`)
) ENGINE = MYISAM ;
+
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;
 
</pre>
 
</pre>

Revision as of 16:53, 7 May 2012

Conditional Auto Tweeter written in PHP

  • Using OAuth Library by Matt Harris: https://github.com/themattharris/tmhOAuth
  • Running via CLI PHP
  • Design an application to use Matt Harris' library as a function to auto tweet events based on existing conditions

Current Functionality

  • Using MidsouthMakersDev Twitter account
  • Able to be run from the command line to post static tweets.
  • Able to be run from a url to post static tweets.
  • Checks pending table and checks if their post date < current time

To Be Done

  • Need to handle adding to pending table
  • Need to handle adding to history
  • Need to handle Remove from pending
  • Cron local system to test for pending tweets

Goals

  • Take input from multiple sources
  • Reliably validate source of all incoming data
  • Use access list or secret hash to prevent abuse

Database Schema

  • Pending Table
CREATE TABLE IF NOT EXISTS `pending` (
  `id` int(6) NOT NULL AUTO_INCREMENT,
  `content` varchar(160) NOT NULL,
  `post_date` datetime NOT NULL,
  `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `source` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;
  • History Table
CREATE TABLE IF NOT EXISTS `history` (
  `id` int(6) NOT NULL AUTO_INCREMENT,
  `content` varchar(160) NOT NULL,
  `post_date` date NOT NULL,
  `added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `source` varchar(255) NOT NULL,
  `response_code` int(4) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;
  • Secrets Table
CREATE TABLE IF NOT EXISTS `secrets` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `source` varchar(255) NOT NULL,
  `secret` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 ;