Skip to content

Instantly share code, notes, and snippets.

@victorcosta12
Forked from wescleymatos/gist:1373001
Created March 6, 2013 17:44
Show Gist options
  • Save victorcosta12/5101356 to your computer and use it in GitHub Desktop.
Save victorcosta12/5101356 to your computer and use it in GitHub Desktop.
<?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;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment