Does anyone know how could I save the tweets after searching in a .txt file? My index file is the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Twitter</title>
</head>
<body>
<?php
require('twitter.class.php');
$twitter = new twitter_class();
echo $twitter->getTweets('tomato', 15);
?>
</body>
</html>
I'm new to all this so I would appreciate any help.
Here is the code to save the tweets:
<?php
require('twitter.class.php');
$twitter = new twitter_class();
$tweets = $twitter->getTweets('tomato', 15);
$currentfile = file_get_contents('tweets.txt');
file_put_contents('tweets.txt', $currentfile.$tweets);
?>
This will append the tweets instead of erasing the data if you don't want to append tweets just do this:
<?php
require('twitter.class.php');
$twitter = new twitter_class();
$tweets = $twitter->getTweets('tomato', 15);
file_put_contents('tweets.txt', $tweets);
?>