将推文搜索结果导出为ex​​cel

时间:2017-03-17 08:09:44

标签: php excel api search twitter

假设我有一个表单,用户输入一个关键字在Twitter上搜索,然后另一个页面将显示提供下载按钮。我想要包含此特定关键字的推文作为excel文件下载。我使用的是php语言。

<?php include "twitteroauth.php";?>
<?php
$consumer = "...";
$consumersecret = "...";
$accesstoken = "...";
$accesstokensecret = "...";
$twitter = new TwitterOAuth($consumer, $consumersecret, $accesstoken, $accesstokensecret);

?>
<html>
<head>
<base href="http://localhost/site2.php/">
<meta charset= "UTF-8"/>
<title>twitter search</title>
</head>
<body>
<form method="get" action="site2.php">
<label> Search:  <input id="<?php echo $_GET["q"];?>" name="q" placeholder="Search Twitter"required="required" type="text" value="" maxlength="1000">
</form>
<?php 
if (isset($_POST['keyword'])){ >get('https://api.twitter.com/1.1/search/tweets.json?q='.$_POST['keyword'].'&result_type=recent&count=50');
foreach($tweets as $tweet){
foreach($tweet as $t){
echo '<img src="'.$t->user->profile_image_url.'"/>'.$t->text.'<br>.';
}
}
}
?>
</body>
</html>

第二页

<!DOCTYPE html>
<html>
<head>
<base href="http://localhost/site1.php.php">
<title>resaults</title>
<a href="http://localhost/site2.php">Download</a>
</body>
</html>

0 个答案:

没有答案