Location: PHPKode > projects > Laikwan WMC > wmc_20070325/gmlite/loadContacts.php
<?
require_once("config.php");

header("Content-type: text/xml; charset=utf-8");  // must use text/xml for ajax/xmlhttp to work :(
header("Pragma: no-cache");  // stop caching	


$gm = new GMailer();
if (!$gm->created)
  die("Failed to create GMailer.");      
quick_init($gm);


if ($gm->connect()) {   
	$gm->fetchBox(GM_CONTACT, "all", 0);
	$ss = $gm->getSnapshot(GM_CONTACT);

	echo "<root>" ;
	for ($ii = 0; $ii < count($ss->contacts) ; $ii++) {
		echo "<contact>";
		echo "<id>".cleanData($ss->contacts[$ii]["id"])."</id>";
		echo "<name>".cleanData($ss->contacts[$ii]["name"])."</name>";
		echo "<email>".cleanData($ss->contacts[$ii]["email"])."</email>";
		echo "</contact>";
	}
	echo "</root>" ;
  
} else {
	echo "<root>" . 
		"<error>Failed to connect</error>" . 
		"</root>";
}

function cleanData($contents){	  
	//$contents = strip_tags($contents);
	$contents = ereg_replace("&amp;", "&", $contents);	 
	$contents = ereg_replace("&nbsp;", " ", $contents);	 
	$contents = ereg_replace("u003d", "=", $contents);	 
	$contents = ereg_replace("src=\"/mail/", "src=\"http://mail.google.com/mail/", $contents);	 
	$contents = ereg_replace("]]>", "]]&gt;", $contents);	 
	return "<![CDATA[" . $contents . "]]>";
}

?>

Return current item: Laikwan WMC