Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit-script I used at WordCampMSP to archive

  • Loading branch information...
commit 40ca86587305dc867c90a2d1ab5959ca5ca0a8a5 0 parents
Mitchell Hislop authored
Showing with 58 additions and 0 deletions.
  1. +10 −0 config.php
  2. +48 −0 techbotmn.php
10 config.php
@@ -0,0 +1,10 @@
+<?php
+$dbhost = 'localhost';
+$dbuser = '';
+$dbpass = '';
+
+$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
+
+$dbname = '';
+mysql_select_db($dbname);
+?>
48 techbotmn.php
@@ -0,0 +1,48 @@
+<?php
+include 'config.php';
+$searchterms=array("#wordcampmsp", '@wordcampmsp');
+
+foreach ($searchterms as $search)
+{
+ $curl=curl_init();
+ $request="http://search.twitter.com/search.json?q={$search}&rpp=100";
+
+ curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
+
+ curl_setopt ($curl, CURLOPT_URL,$request);
+
+ $responseT = curl_exec ($curl);
+
+ curl_close($curl);
+ $oresponseT = json_decode($responseT);
+ var_dump($oresponseT);
+
+ foreach($oresponseT->results as $res)
+ {
+ $id=$res->id;
+ $author=$res->from_user;
+ $message=$res->text;
+ $message_time=date('Y-m-d H:i:s', strtotime($res->created_at));
+
+ $query = "SELECT * FROM `".$dbname."` WHERE `message_id` = '".mysql_real_escape_string($id)."'";
+ $res = mysql_query($query);
+ if(mysql_num_rows($res) == 0)
+ {
+
+ //MySQL insert
+ $query = "INSERT INTO `".$dbname."` (message_id, author, message) VALUES ('".mysql_real_escape_string($id)."', '".mysql_real_escape_string($author)."', '".mysql_real_escape_string($message)."'`)";
+ echo "New Tweet: {$message}\n";
+ mysql_query($query) or die("Insert failed \n");
+ }
+
+
+
+
+
+ }
+
+}
+
+
+
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.