gnu-social/plugins/YammerImport/yammer-import.php

42 lines
1.3 KiB
PHP
Raw Normal View History

<?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($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";
}
$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'] == 'group') {
$group = $imp->importGroup($item);
echo "Imported Yammer group " . $item['id'] . " as $group->nickname ($group->id)\n";
}
}
// Process in reverse chron order...
// @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) {
$notice = $imp->importNotice($item);
echo "Imported Yammer notice " . $item['id'] . " as $notice->id\n";
}