【发布时间】:2014-09-04 14:59:03
【问题描述】:
我想打印回复中的所有推文。我错过了什么?
https://github.com/J7mbo/twitter-api-php
<?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' => "",
'oauth_access_token_secret' => "",
'consumer_key' => "",
'consumer_secret' => ""
);
/** Perform a GET request and echo the response **/
/** Note: Set the GET field BEFORE calling buildOauth(); **/
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=%23twitter';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
foreach ($response->statuses as $tweet) {
echo $tweet->text;
}
注意:试图获取非对象的属性 /var/www/projects/twitter/twitter-api-php/index.php 在第 23 行
警告:为 foreach() 提供的参数无效 /var/www/projects/twitter/twitter-api-php/index.php 在第 23 行
【问题讨论】: