diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-23 16:40:22 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-28 07:44:24 -0700 |
commit | ae507b04856804acb41256a00a9cd2c8e7136c96 (patch) | |
tree | 022cf86f319fa06703ae92181abe5e13e016770b /plugins/YammerImport/scripts | |
parent | e8ad436a99401c36cc7fcf7e8d14d3bc00cdd3d3 (diff) |
Work in progress: most of the infrastructure for running import via BG queues or CLI script is now in place (untested, no UI, needs tweaks & fixes)
Diffstat (limited to 'plugins/YammerImport/scripts')
-rw-r--r-- | plugins/YammerImport/scripts/yammer-import.php | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/plugins/YammerImport/scripts/yammer-import.php b/plugins/YammerImport/scripts/yammer-import.php index ac258e1c7..24307d6cd 100644 --- a/plugins/YammerImport/scripts/yammer-import.php +++ b/plugins/YammerImport/scripts/yammer-import.php @@ -8,34 +8,37 @@ define('INSTALLDIR', dirname(dirname(dirname(dirname(__FILE__))))); require INSTALLDIR . "/scripts/commandline.inc"; -// temp stuff -require 'yam-config.php'; -$yam = new SN_YammerClient($consumerKey, $consumerSecret, $token, $tokenSecret); -$imp = new YammerImporter($yam); +$runner = YammerRunner::init(); -// First, import all the users! -// @fixme follow paging -- we only get 50 at a time -$data = $yam->users(); -foreach ($data as $item) { - $user = $imp->importUser($item); - echo "Imported Yammer user " . $item['id'] . " as $user->nickname ($user->id)\n"; -} +switch ($runner->state()) +{ + case 'init': + $url = $runner->requestAuth(); + echo "Log in to Yammer at the following URL and confirm permissions:\n"; + echo "\n"; + echo " $url\n"; + echo "\n"; + echo "Pass the resulting code back by running:\n" + echo "\n" + echo " php yammer-import.php --auth=####\n"; + echo "\n"; + break; -// Groups! -// @fixme follow paging -- we only get 20 at a time -$data = $yam->groups(); -foreach ($data as $item) { - $group = $imp->importGroup($item); - echo "Imported Yammer group " . $item['id'] . " as $group->nickname ($group->id)\n"; -} + case 'requesting-auth': + if (empty($options['auth'])) { + echo "Please finish authenticating!\n"; + break; + } + $runner->saveAuthToken($options['auth']); + // Fall through... -// Messages! -// Process in reverse chron order... -// @fixme follow paging -- we only get 20 at a time, and start at the most recent! -$data = $yam->messages(); -$messages = $data['messages']; -$messages = array_reverse($messages); -foreach ($messages as $item) { - $notice = $imp->importNotice($item); - echo "Imported Yammer notice " . $item['id'] . " as $notice->id\n"; -} + default: + while (true) { + echo "... {$runner->state->state}\n"; + if (!$runner->iterate()) { + echo "... done.\n"; + break; + } + } + break; +}
\ No newline at end of file |