diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-21 15:54:39 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-21 15:54:39 -0700 |
commit | 3e2cf3876db1cdb546f9bc9c16b2f28ceb693107 (patch) | |
tree | 6e03acd0593eec7db8ff2522aa347a9fdc048a50 /plugins | |
parent | 5b9efbb5014307c6ed3e4cf9a6e87ceb4331c223 (diff) |
Initial semi-working yammer import :D
* no avatars
* no details of user accounts or their auth info
* no group memberships or subscriptions
* no attachments
* will probably esplode if >20 messages in your network *whistle innocently*
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/YammerImport/yammer-import.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/YammerImport/yammer-import.php b/plugins/YammerImport/yammer-import.php new file mode 100644 index 000000000..d6ec97513 --- /dev/null +++ b/plugins/YammerImport/yammer-import.php @@ -0,0 +1,59 @@ +<?php + +if (php_sapi_name() != 'cli') { + die('no'); +} + +define('INSTALLDIR', 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(); + +$data = $yam->messages(); +/* + ["messages"]=> + ["meta"]=> // followed_user_ids, current_user_id, etc + ["threaded_extended"]=> // empty! + ["references"]=> // lists the users, threads, replied messages, tags +*/ + +// 1) we're getting messages in descending order, but we'll want to process ascending +// 2) we'll need to pull out all those referenced items too? +// 3) do we need to page over or anything? + +// 20 qualifying messages per hit... +// use older_than to grab more +// (better if we can go in reverse though!) +// meta: The older-available element indicates whether messages older than those shown are available to be fetched. See the older_than parameter mentioned above. +foreach ($data['references'] as $item) { + if ($item['type'] == 'user') { + $user = $imp->importUser($item); + echo "Imported Yammer user " . $item['id'] . " as $user->nickname ($user->id)\n"; + } else if ($item['type'] == 'group') { + $group = $imp->importGroup($item); + echo "Imported Yammer group " . $item['id'] . " as $group->nickname ($group->id)\n"; + } else if ($item['type'] == 'tag') { + // could need these if we work from the parsed message text + // otherwise, the #blarf in orig text is fine. + } else if ($item['type'] == 'thread') { + // Shouldn't need thread info; we'll reconstruct conversations + // from the reply-to chains. + } else if ($item['type'] == 'message') { + // If we're processing everything, then we don't need the refs here. + } else { + echo "(skipping unknown ref: " . $item['type'] . ")\n"; + } +} + +// Process in reverse chron order... +// @fixme follow paging +$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"; +} |