ZERO_RESULTS from the geocode API for business zip codes

We recently ran into a scenario where finding a zip code internationally was not producing any results.

http://maps.googleapis.com/maps/api/geocode/json?components=country:Switzerland|postal_code:4901

{
   "results" : [],
   "status" : "ZERO_RESULTS"
}

We read a little more into the zip code structure in Switzerland and found that it’s a business zip code and didn’t provide lat/lng data like a normal zipcode would (apparently 4901 has a parent zip code of 4900) — that wasn’t helpful news tho.  However, we found a way that hacks the other API structure using the “address” parameter instead of “components”.  You just need to add the word “country” before it – otherwise the results find information to an address in Michigan.

https://maps.googleapis.com/maps/api/geocode/json?address=country Switzerland 4901

The above URL was able to get us the data that we needed for finding locations that were near this zip code.  We haven’t had any rogue results from this method, so hopefully this can help someone else out in the future.

Enumerate Gmail Contacts

Here’s some sample code I’ve piled together to list gmail contacts:

require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
Zend_Loader::loadClass('Zend_Gdata_Query');

$user = 'user@gmail.com';
$pass = 'password';

// Using Client Login
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, 'cp');
$gdata = new Zend_Gdata($client);
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/'.$user.'/full');
$query->setMaxResults(100);
$feed = $gdata->getFeed($query);

$xml = new SimpleXMLElement($feed->getXML());
$entries = $xml->children('http://www.w3.org/2005/Atom');

foreach ($entries->entry as $entry )
{
	$defaults = $entry->children('http://schemas.google.com/g/2005');
	echo 'title: '. $entry->title."\n";
	if(isset($defaults->email))
	{
		echo ' email: '.$defaults->email->attributes()->address."\n";
	}
	echo ' address: '.$defaults->postalAddress."\n";
	echo "\n";
}

Highrise API Wrapper

Since Soocial no longer syncs with highrise, I’ve been looking for another solution to sync with my google apps.  I’ve decided I’ll be writing my own, which I will release later.

In the mean time, I’ve found a Highrise API wrapper which should come in handy so I don’t have to deal with cURL as much.

include("push2Highrise.php");
$p = Push_Highrise();
$p->pushContact($_REQUEST);
$p->pushTask($_REQUEST);
$p->pushNote($_REQUEST);
$p->pushDeal($_REQUEST);

Soocial Highrise Sync

There were two main reasons I went with Highrise for CRM.  First, because of its simplicity, and second because of its ability to sync with Soocial.  This functionality is advertised on their website yet when you go to actually do the sync, Soocial states that 37 Signals has requested they disable synchronization.

Why?

A little investigation points the finger at Soocial.  There were bugs in their implementation that resulted in the deletion and recreation of contacts, removing relations and detaching deals and cases from the contacts.

It looks like I’ll be writing my own implementation eventually using the Highrise API and the Google Apps API.

Gmail Labs Escape Hatch

If (when) a Labs feature breaks, and you’re having trouble loading your inbox, there’s an escape hatch. Use http://mail.google.com/mail/?labs=0.

The same for google apps

Use http://mail.google.com/a/[domain name]/?labs=0. Replace [domain name] with your google apps domain.