/ Published in: PHP
Expand |
Embed | Plain Text
<?php $q = $_GET["q"]; // query string $jsonobj = json_decode($response); if($jsonobj != null){ if (!$con){ } foreach($jsonobj->results as $item){ $id = $item->id; $created_at = $item->created_at; $from_user_id = $item->from_user_id; $geo = $item->geo; $iso_language_code = $item->iso_language_code; $to_user_id = $item->to_user_id; if($to_user_id==""){ $to_user_id = 0; } // SQL query to create table available at http://snipplr.com/view/56995/sql-query-to-create-a-table-in-mysql-to-store-tweets/ $query = "INSERT into tweets VALUES ($id,'$mysqldate','$from_user',$from_user_id,'$text','$source','$geo','$iso_language_code','$profile_image_url',$to_user_id,'$q')"; } } ?>
Comments
Subscribe to comments
You need to login to post a comment.

Can't seem to get this one to work with the database. I get now error and no data in the database.
I've configured it with my own database information but nothing happens when I open this file in a browser window. Am I missing something?
Hope for some help here :)
@skavhellen - which version of MySQL have you got installed? You need 5.2 or above as this script makes use of the json_decode function.
Dear,
Warning: Invalid argument supplied for foreach() in /home/kso/publichtml/gettweet.php on line 27
please find my code and let me know where is the mistake.
apprecite your feedback....
$username='hangover_2011'; // set user name $format='json'; // set format
$q = $GET["q"]; // query string $request = "http://api.twitter.com/1/statuses/usertimeline/{$username}.{$format}".urlencode($q); $response = filegetcontents($request); $jsonobj = json_decode($response);
if($jsonobj != null){
foreach ($jsonobj->results as $status) {
}
mysql_close($con); }