Skip to content

Commit

Permalink
Better support for Twitter API errors
Browse files Browse the repository at this point in the history
  • Loading branch information
graulund committed Jul 2, 2013
1 parent 252ebbe commit 3eff4df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions maintenance/loadtweets.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ function importTweets($p){
if(!empty($data)){
echo l("<ul>");
foreach($data as $i => $tweet){

// First, let's check if an API error occured
if(is_array($tweet) && is_object($tweet[0]) && property_exists('message', $tweet[0])){
dieout(l(bad('A Twitter API error occured: ' . $tweet[0]->message)));
}

// Shield against duplicate tweet from max_id
if(!IS64BIT && $i == 0 && $maxID == $tweet->id_str){ unset($data[0]); continue; }
// List tweet
Expand Down Expand Up @@ -192,6 +198,12 @@ function importTweets($p){
if(!empty($data)){
echo l("<ul>");
foreach($data as $i => $tweet){

// First, let's check if an API error occured
if(is_array($tweet) && is_object($tweet[0]) && property_exists('message', $tweet[0])){
dieout(l(bad('A Twitter API error occured: ' . $tweet[0]->message)));
}

if(!IS64BIT && $i == 0 && $maxID == $tweet->id_str){ unset($data[0]); continue; }
if($tweet->user->id_str == $uid){
echo l("<li>" . $tweet->id_str . " " . $tweet->created_at . "</li>\n");
Expand Down

0 comments on commit 3eff4df

Please sign in to comment.