Created
November 17, 2011 12:02
-
-
Save wescleymatos/1373001 to your computer and use it in GitHub Desktop.
Pegar timeline do twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
o contador não está servindo para nada.