]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/YammerImport/scripts/yammer-import.php
ac258e1c7d411abe620d8089696ca71454abc621
[quix0rs-gnu-social.git] / plugins / YammerImport / scripts / yammer-import.php
1 <?php
2
3 if (php_sapi_name() != 'cli') {
4     die('no');
5 }
6
7 define('INSTALLDIR', dirname(dirname(dirname(dirname(__FILE__)))));
8
9 require INSTALLDIR . "/scripts/commandline.inc";
10
11 // temp stuff
12 require 'yam-config.php';
13 $yam = new SN_YammerClient($consumerKey, $consumerSecret, $token, $tokenSecret);
14 $imp = new YammerImporter($yam);
15
16 // First, import all the users!
17 // @fixme follow paging -- we only get 50 at a time
18 $data = $yam->users();
19 foreach ($data as $item) {
20     $user = $imp->importUser($item);
21     echo "Imported Yammer user " . $item['id'] . " as $user->nickname ($user->id)\n";
22 }
23
24 // Groups!
25 // @fixme follow paging -- we only get 20 at a time
26 $data = $yam->groups();
27 foreach ($data as $item) {
28     $group = $imp->importGroup($item);
29     echo "Imported Yammer group " . $item['id'] . " as $group->nickname ($group->id)\n";
30 }
31
32 // Messages!
33 // Process in reverse chron order...
34 // @fixme follow paging -- we only get 20 at a time, and start at the most recent!
35 $data = $yam->messages();
36 $messages = $data['messages'];
37 $messages = array_reverse($messages);
38 foreach ($messages as $item) {
39     $notice = $imp->importNotice($item);
40     echo "Imported Yammer notice " . $item['id'] . " as $notice->id\n";
41 }