| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (php_sapi_name() != 'cli') { | 
					
						
							|  |  |  |     die('no'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-22 12:52:34 -07:00
										 |  |  | define('INSTALLDIR', dirname(dirname(dirname(dirname(__FILE__))))); | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | require INSTALLDIR . "/scripts/commandline.inc"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // temp stuff
 | 
					
						
							|  |  |  | require 'yam-config.php'; | 
					
						
							|  |  |  | $yam = new SN_YammerClient($consumerKey, $consumerSecret, $token, $tokenSecret); | 
					
						
							| 
									
										
										
										
											2010-09-21 17:08:40 -07:00
										 |  |  | $imp = new YammerImporter($yam); | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 18:15:32 -07:00
										 |  |  | // 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"; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 23:19:36 -07:00
										 |  |  | // 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"; | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-21 23:19:36 -07:00
										 |  |  | // Messages!
 | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | // Process in reverse chron order...
 | 
					
						
							| 
									
										
										
										
											2010-09-21 18:15:32 -07:00
										 |  |  | // @fixme follow paging -- we only get 20 at a time, and start at the most recent!
 | 
					
						
							| 
									
										
										
										
											2010-09-21 23:19:36 -07:00
										 |  |  | $data = $yam->messages(); | 
					
						
							| 
									
										
										
										
											2010-09-21 15:54:39 -07:00
										 |  |  | $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"; | 
					
						
							|  |  |  | } |