title: How to solve Android GCM 401 Error?
body: <p>Have setup a project at Google Code APis console and have a server key at "Key for server apps (with IP locking)". I'am trying to send a push notification to GCM device using "API key" and one registration ID that I have stored at database.</p>
  
  <p>For server side I'am using Zend_Mobile_Push_Gcm and have something like this:</p>
  
  <pre><code>$token = 'REGISTRATION ID';
  $apiKey = 'API KEY';
  
  //Send test push
  $message = new Zend_Mobile_Push_Message_Gcm();
  $message-&gt;setId(time());
  $message-&gt;addToken($token);
  $message-&gt;setData(array('foo' =&gt; 'bar', 'bar'=&gt;'foo'));
  
  $gcm = new Zend_Mobile_Push_Gcm();
  $gcm-&gt;setApiKey($apiKey);
  
  try {
      $response = $gcm-&gt;send($message);
  } catch (Zend_Mobile_Push_Exception $e) {
      die($e-&gt;getMessage());
  }
  </code></pre>
  
  <p>On the app side, I have used the GCM demo, that is currently registering it's registration ID on a server service.</p>
  
  <p>I'am not able to send the push, always get a 401 error. Have gone through troubleshooting and tried my API KEY and Registration ID with the CLI test line at <a href="http://developer.android.com/guide/google/gcm/gcm.html#auth_error" rel="nofollow">http://developer.android.com/guide/google/gcm/gcm.html#auth_error</a> but with no success.</p>
  
  <p>Any help would be appreciated.</p>