Permalink
Browse files

Schutz vor fehlerhaften Daten von Twitter

  • Loading branch information...
1 parent aabb4af commit 1fa0edffdf3db266806b630058a5ae0ad5f8c7ab @jk committed May 10, 2009
Showing with 12 additions and 0 deletions.
  1. +12 −0 getFollower.php
View
@@ -8,11 +8,21 @@
mkdir(USERDIR, 0755);
}
+$yesterday = strftime("%Y%m%d", strtotime('-1 day', mktime()));
+
+$fileYesterday = USERDIR.'/'.$yesterday.'_'.strtolower(USER).".txt";
$filename = USERDIR.'/'.strftime("%Y%m%d").'_'.strtolower(USER).".txt";
+
if (file_exists($filename)) {
exit($filename.' already exists.'."\n");
}
+define('FLAG_YESTERDAY_EXISTS', file_exists($fileYesterday));
+
+$countYesterday = 0;
+if (FLAG_YESTERDAY_EXISTS)
+ $countYesterday = count(explode("\n", file_get_contents($fileYesterday)));
+
// Twitter
define('USER_URL', 'http://twitter.com/users/show/'.USER.'.xml');
define('FOLLOWER_URL', 'http://twitter.com/statuses/followers.xml');
@@ -87,6 +97,8 @@ function printList($arr) {
if (count($o) < 1) {
exit("No followers were found. That's unlikey so that no file was created.\n");
+} elseif (FLAG_YESTERDAY_EXISTS && ($countYesterday * 0.8 >= count($o))) {
+ exit("More than a 20% follower lost opposed to yesterday. It's very likely that a dataloss occured.");
}
sort($o);

0 comments on commit 1fa0edf

Please sign in to comment.