]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/YammerImport/yammer-import.php
Fetch more user data in Yammer imports, including the primary email address (preconfi...
[quix0rs-gnu-social.git] / plugins / YammerImport / yammer-import.php
index da99c48e903c5f2e085a6950ecf728692631edec..7241809ba05733e4095604eb0d00821daf1c23af 100644 (file)
@@ -13,44 +13,26 @@ require 'yam-config.php';
 $yam = new SN_YammerClient($consumerKey, $consumerSecret, $token, $tokenSecret);
 $imp = new YammerImporter($yam);
 
-$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?
+// 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";
+}
 
-// 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.
+$data = $yam->messages();
+// @fixme pull the full group list; this'll be a partial list with less data
+// and only for groups referenced in the message set.
 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') {
+    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
+// @fixme follow paging -- we only get 20 at a time, and start at the most recent!
 $messages = $data['messages'];
 $messages = array_reverse($messages);
 foreach ($messages as $item) {