El código php a continuación debería funcionar, sin embargo, recibo un error, una respuesta vacía, de mi servidor. Intenté apagar el firewall pero no tuve suerte. ¿Pueden ayudarme? He estado probando diferentes métodos durante mucho tiempo. No tengo idea de qué es lo que falla. Gracias.
<?php 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' => "" ); $url = "https://api.twitter.com/1.1/search/tweets.json"; $requestMethod = "GET"; $getfield = '?q=cloud%20computing&count=5&result_type=popular'; $twitter = new TwitterAPIExchange($settings); echo $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); ?>necesita usar json_decode: http://php.net/manual/en/function.json-decode.php
<?php error_reporting(E_ALL); ini_set("display_errors", 1); require_once('TwitterAPIExchange.php'); $settings = array( 'oauth_access_token' => "xxx", 'oauth_access_token_secret' => "xxx", 'consumer_key' => "xxx", 'consumer_secret' => "xxx" ); $url = "https://api.twitter.com/1.1/search/tweets.json"; $requestMethod = "GET"; $getfield = '?q=cloud%20computing&count=5&result_type=popular'; $twitter = new TwitterAPIExchange($settings); $response = $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); $string = json_decode($response, true); // there you handle twitter response print_r($string); // here is the echo'd result, not needed after // from here, you have access to the data // then, a foreach loop will give you access to whatever you want to echo foreach($string['statuses'] as $tweets) { $tweet = $tweets['text']; echo "<p>Tweet: $tweet </p>"; } ?>actualizado con el ejemplo de bucle