summaryrefslogtreecommitdiff
path: root/plugins/YammerImport/scripts/yammer-import.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/YammerImport/scripts/yammer-import.php')
-rw-r--r--plugins/YammerImport/scripts/yammer-import.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/YammerImport/scripts/yammer-import.php b/plugins/YammerImport/scripts/yammer-import.php
new file mode 100644
index 000000000..ac258e1c7
--- /dev/null
+++ b/plugins/YammerImport/scripts/yammer-import.php
@@ -0,0 +1,41 @@
+<?php
+
+if (php_sapi_name() != 'cli') {
+ die('no');
+}
+
+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);
+
+// 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";
+}
+
+// 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";
+}
+
+// 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";
+}