Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Created November 17, 2011 12:02
Show Gist options
  • Save wescleymatos/1373001 to your computer and use it in GitHub Desktop.
Save wescleymatos/1373001 to your computer and use it in GitHub Desktop.
Pegar timeline do twitter
<?php
function pegatwitter($usuario, $qtd = 10){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://twitter.com/statuses/user_timeline/' . $usuario . '.json?count=' . $qtd,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true)
);
$request = curl_exec($curl);
curl_close($curl);
$json = json_decode($request);
$tweets = array();
$cont=0;
foreach ($json as $twitter) {
$tweets[$cont]['tweet'] = $twitter->text;
$tweets[$cont]['via'] = $twitter->source;
$tweets[$cont]['data'] = $twitter->created_at;
$cont++;
}
return $tweets;
}
?>
@victorcosta12
Copy link

o contador não está servindo para nada.

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