title: GCM messages not getting to API or sent, but success flag returned
body: <p>I am trying to set up Google Cloud Messaging on Android with PHP (following this tutorial: <a href="http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/" rel="nofollow">http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/</a>). My device registers successfully with GCM and then with the server (the regId is stored into the database). </p>
  
  <p>When I try and send to the device nothing is received, although I get this response:</p>
  
  <p>{"multicast_id":4701392840778619841,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1355907831651938%978fee92f9fd7ecd"}]}</p>
  
  <p>Google API reports that no requests have been made.</p>
  
  <p>This is my send_notification function in PHP:</p>
  
  <pre><code>    public function send_notification($registration_ids, $message) {
      // include config
      include_once './config.php';
  
      // Set POST variables
      $url = 'https://android.googleapis.com/gcm/send';
  
      $fields = array(
          'registration_ids' =&gt; $registration_ids,
          'data' =&gt; $message,
      );
  
      $headers = array(
          'Authorization: key=' . GOOGLE_API_KEY,
          'Content-Type: application/json'
      );
      // Open connection
      $ch = curl_init();
  
      // Set the url, number of POST vars, POST data
      curl_setopt($ch, CURLOPT_URL, $url);
  
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  
      // Disabling SSL Certificate support temporarly
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
  
      // Execute post
      $result = curl_exec($ch);
      if ($result === FALSE) {
          die('Curl failed: ' . curl_error($ch));
      }
  
      // Close connection
      curl_close($ch);
      echo $result;
  }
  </code></pre>
  
  <p>From research, I have seen similar questions have been asked to this, however they vary slightly - for example, different programming languages and no solution that I have found has solved this problem.</p>
  
  <p><strong>Extra Info:</strong></p>
  
  <p><strong>1.</strong> I have checked and cURL is enabled.  </p>
  
  <p><strong>2.</strong> My onMessage method</p>
  
  <pre><code>protected void onMessage(Context context, Intent intent) {
      Log.i(TAG, "Received message");
      String message = intent.getExtras().getString("price");
  
      displayMessage(context, message);
      // notifies user
      generateNotification(context, message);
  }
  </code></pre>
  
  <p>(price in the above just retrieves the message as its stored like this: $message = array("price" => $message); before being given as a parameter to the send_notification function on the server. </p>
  
  <p>I have checked LogCat and 'Received message' does not appear. </p>