Skip to content

Instantly share code, notes, and snippets.

@porfidev
Created August 8, 2015 17:01
Show Gist options
  • Save porfidev/25743318bb7ef27aa239 to your computer and use it in GitHub Desktop.
Save porfidev/25743318bb7ef27aa239 to your computer and use it in GitHub Desktop.
API Twitter 2015: Mostrar los últimos 10 tweets de un usuario
<?php
/**
* Created by PhpStorm.
* User: elporfirio
* Date: 08/08/15
* Time: 10:56
*/
require "twitteroauth-master/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$consumer_key = "XXXX";
$consumer_secret = "XXXX";
$token = "XXXX";
$token_secret = "XXXX";
$conexion = new TwitterOAuth($consumer_key, $consumer_secret, $token, $token_secret);
#$contenido = $conexion->get("followers/list");
$contenido = $conexion->get("statuses/user_timeline", ["screen_name" => "SaraSoueidan", "count" => 10]);
$html = "";
$i = 1;
foreach($contenido as $tweet){
$html .= $i . ">>> ";
$html .= $tweet->text;
$html .= "<hr>";
$i ++;
}
echo $html;
@PterPmnta
Copy link

Disculpa, sabes como hacer esto pero de forma streaming, que cuando publique un tweet, de forma inmediata llegue a donde tenga conectado el servicio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment