3 if (php_sapi_name() != 'cli') {
8 define('INSTALLDIR', dirname(dirname(dirname(dirname(__FILE__)))));
10 $longoptions = array('verify=', 'reset');
11 require INSTALLDIR . "/scripts/commandline.inc";
13 echo "Checking current state...\n";
14 $runner = YammerRunner::init();
16 if (have_option('reset')) {
17 echo "Resetting Yammer import state...\n";
21 switch ($runner->state())
24 echo "Requesting authentication to Yammer API...\n";
25 $url = $runner->requestAuth();
26 echo "Log in to Yammer at the following URL and confirm permissions:\n";
30 echo "Pass the resulting code back by running:\n";
32 echo " php yammer-import.php --verify=####\n";
36 case 'requesting-auth':
37 if (!have_option('verify')) {
38 echo "Awaiting authentication...\n";
40 echo "If you need to start over, reset the state:\n";
42 echo " php yammer-import.php --reset\n";
46 echo "Saving final authentication token for Yammer API...\n";
47 $runner->saveAuthToken(get_option_value('verify'));
51 while ($runner->hasWork()) {
52 echo "... {$runner->state()}\n";
53 if (!$runner->iterate()) {
57 if ($runner->isDone()) {
60 echo "... no more import work scheduled.\n";