<?php
require 'app_tokens.php';
require 'tmhOAuth-master/tmhOAuth.php';
$connection = new tmhOAuth(array(
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret,
'user_token' => $user_token,
'user_secret' => $user_secret
));
$mongo = new Mongo();
$db = $mongo->twitter;
$collection = $db->tweets;
$screen_name = "learnmongo";
$http_code = $connection->request('GET', $connection->url('1.1/search/tweets'));
if ($http_code == 200) {
$twitter = "http://api.twitter.com/1.1/statuses/user_timeline.json?";
$curl = curl_init($twitter);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$usertimeline = curl_exec($curl);
curl_close($curl);
$usertimeline = json_decode($usertimeline);
foreach ($usertimeline as $id => $item) {
$collection->insert($item);
}
}
现在我已经尝试过这个代码。它只显示一个空白页面。没有打印错误信息,但是在mondodb中没有添加推文。你告诉为什么会这样?