X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=scripts%2Fsynctwitterfriends.php;h=fe53ff44d634fa92895dd00c34ccc804fa245295;hb=db4ffca5350a11835c2c990f8d77d7cabb365a43;hp=794301f0f02f8b4af9f6fae0294f1a2bc6ec4c2b;hpb=e5657ca4bbd8a43bf2dd44c2554e807a45224bd7;p=quix0rs-gnu-social.git diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php index 794301f0f0..fe53ff44d6 100755 --- a/scripts/synctwitterfriends.php +++ b/scripts/synctwitterfriends.php @@ -2,7 +2,7 @@ . */ -// Abort if called from a web server -if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) { - print "This script must be run from the command line\n"; - exit(); -} - define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); -define('LACONICA', true); // Uncomment this to get useful console output -//define('SCRIPT_DEBUG', true); -require_once(INSTALLDIR . '/lib/common.php'); +$helptext = <<service = 1; // Twitter +$flink->orderBy('last_friendsync'); +$flink->limit(25); // sync this many users during this run $cnt = $flink->find(); print "Updating Twitter friends subscriptions for $cnt users.\n"; @@ -60,8 +74,11 @@ while ($flink->fetch()) { continue; } - $result = save_twitter_friends($user, $fuser->id, - $fuser->nickname, $flink->credentials); + save_twitter_friends($user, $fuser->id, $fuser->nickname, $flink->credentials); + + $flink->last_friendsync = common_sql_now(); + $flink->update(); + if (defined('SCRIPT_DEBUG')) { print "\nDONE\n"; } else { @@ -70,4 +87,18 @@ while ($flink->fetch()) { } } +function lockFilename() +{ + $piddir = common_config('daemon', 'piddir'); + if (!$piddir) { + $piddir = '/var/run'; + } + + return $piddir . '/synctwitterfriends.lock'; +} + +// Cleanup +fclose($lockfile); +unlink($lockfilename); + exit(0);