2013-07-31 219 views
3

我正在尝试使用Twitters API来检索哈希标签结果列表 - 它过去很容易,因为它们不需要身份验证,但现在它变得对我来说很棘手......twitter api 1.1 - 返回NULL

我按照这个帖子https://stackoverflow.com/questions/12916539/simplest-php-example-for-retrieving-user-timeline-with-twitter-api-version-1-1/15314662#=

但是,当我载入我的网页,它只是显示为空 - 我相信我所做的每一件事情正确

通知 - 下面的PHP文件在同一目录下文件TwitterAPIExchange

帮助,将不胜感谢

<?php 
ini_set('display_errors', 1); 
require_once('TwitterAPIExchange.php'); 

/** Set access tokens here - see: https://dev.twitter.com/apps/ **/ 
$settings = array(
    'oauth_access_token' => "xxxxx", 
    'oauth_access_token_secret' => "xxxxx", 
    'consumer_key' => "xxxxx", 
    'consumer_secret' => "xxxxx" 
); 

$url = 'https://api.twitter.com/1.1/statuses/user_timeline.json'; 
$getfield = '?screen_name=j7mbo'; 
$requestMethod = 'GET'; 

$twitter = new TwitterAPIExchange($settings); 
$response = $twitter->setGetfield($getfield) 
        ->buildOauth($url, $requestMethod) 
        ->performRequest(); 
var_dump(json_decode($response)); 
?> 
+1

'的error_reporting(E_ALL);' – Sammitch

+0

你可能不希望发布你的秘密令牌 –

+0

什么HTTP状态代码是你找回?您有机会在当前时间范围内达到您的查询限制。但是,如果它从未奏效,那可能不是这样。 –

回答

8

将CURLOPT_SSL_VERIFYPEER => false添加到TwitterAPIExchange.php中performRequest()方法内的CURL选项。这似乎解决了它。

CF here

+0

我加了,没有任何反应。任何想法 ? – Chester

2

它适用于我的罚款。我的结果在这里:http://pastebin.com/FB1zpuuT

首先验证您是否可以在您的网络浏览器中连接到此设备。 https://api.twitter.com/1.1/statuses/user_timeline.json

如果你可以连接到,你会看到一条错误消息。如果没有,问题可能是您的网络阻止Twitter或Twitter阻止您的IP地址。

+0

wierd as hell - 当我在浏览器中尝试链接时显示错误消息...但代码仍显示为NULL =/ – Hashey100

+0

这是我的第二个PHP应用程序Twitter API v1.1和TwitterAPIExchange。第一个应用程序效果很好,但我遇到与您完全相同的结果:返回null。我尝试重置我的“使用者密钥”和“使用者密码”,并在我的配置文件中替换密钥,但仍然收到'null'。当我尝试连接到@Terry的链接时出现错误。 – Anthony