]> git.mxchange.org Git - friendica-addons.git/blob - twitter/twitter_sync.php
Tumblr: Added support for hook "support_probe"
[friendica-addons.git] / twitter / twitter_sync.php
1 <?php
2
3 use Friendica\Core\Logger;
4 use Friendica\DI;
5
6 function twitter_sync_run($argv, $argc)
7 {
8         require_once 'addon/twitter/twitter.php';
9
10         if (function_exists('sys_getloadavg')) {
11                 $load = sys_getloadavg();
12                 $maxload = DI::config()->get('system', 'maxloadavg', 50);
13                 if (intval($load[0]) > $maxload) {
14                         Logger::notice('load too high. Twitter sync deferred to next scheduled run.', ['current' => $load[0], 'max' => $maxload]);
15                         return;
16                 }
17         }
18
19         if ($argc < 3) {
20                 return;
21         }
22
23         $mode = intval($argv[1]);
24         $uid = intval($argv[2]);
25
26         if ($mode == 1) {
27                 twitter_fetchtimeline($uid);
28         } elseif ($mode == 2) {
29                 twitter_fetchhometimeline($uid);
30         }
31 }