forked from amwhalen/archive-my-tweets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcron.php
47 lines (36 loc) · 1.02 KB
/
cron.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if (!file_exists(dirname(__FILE__).'/config.php')) {
die("Missing config.php file. Copy config.example.php to config.php and customize the settings.\n");
}
require_once('includes.php');
$isCLI = (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']));
$isWeb = (isset($_GET['secret']) && $_GET['secret'] == TWITTER_CRON_SECRET);
if ($isCLI || $isWeb) {
$amt = new \AMWhalen\ArchiveMyTweets\App($config);
// Import JSON from an official twitter archive
// monthly .js files should be in a folder called 'json'
$importOutput = $amt->importJSON(dirname(__FILE__) . '/json');
if ($isWeb) {
echo '<pre>' . $importOutput . '</pre>';
} else {
echo $importOutput;
}
// API tweets
$archiveOutput = $amt->archive();
if ($isWeb) {
echo '<pre>' . $archiveOutput . '</pre>';
} else {
echo $archiveOutput;
}
// favorite tweets
$archiveOutput = $amt->archiveFavorites();
if ($isWeb) {
echo '<pre>' . $archiveOutput . '</pre>';
} else {
echo $archiveOutput;
}
} else {
echo "Not authorized.\n";
exit(1);
}
?>