]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/YammerImport/scripts/yammer-import.php
Work in progress: most of the infrastructure for running import via BG queues or...
[quix0rs-gnu-social.git] / plugins / YammerImport / scripts / yammer-import.php
1 <?php
2
3 if (php_sapi_name() != 'cli') {
4     die('no');
5 }
6
7 define('INSTALLDIR', dirname(dirname(dirname(dirname(__FILE__)))));
8
9 require INSTALLDIR . "/scripts/commandline.inc";
10
11 $runner = YammerRunner::init();
12
13 switch ($runner->state())
14 {
15     case 'init':
16         $url = $runner->requestAuth();
17         echo "Log in to Yammer at the following URL and confirm permissions:\n";
18         echo "\n";
19         echo "    $url\n";
20         echo "\n";
21         echo "Pass the resulting code back by running:\n"
22         echo "\n"
23         echo "    php yammer-import.php --auth=####\n";
24         echo "\n";
25         break;
26
27     case 'requesting-auth':
28         if (empty($options['auth'])) {
29             echo "Please finish authenticating!\n";
30             break;
31         }
32         $runner->saveAuthToken($options['auth']);
33         // Fall through...
34
35     default:
36         while (true) {
37             echo "... {$runner->state->state}\n";
38             if (!$runner->iterate()) {
39                 echo "... done.\n";
40                 break;
41             }
42         }
43         break;
44 }