title: GCM push notification return error: field data must be a json array
body: <p>When I am using GCM for push notification , I got an error return as: field "data" must be a JSON array. 
  When user create the new post then notification will be send to all Registered devices. Any one have some idea of how to solve it? Thank you.</p>
  
  <pre><code>function Notification($post) {
      global $wpdb;
      $pub_post = get_post($post_ID);
      $post_title=$pub_post-&gt;post_title;
      $totalrecord = $this-&gt;get_allrecord(); 
  
       $message = "Your New post, " .$post_title." has been published";
        if (count($totalrecord) &gt; 0) {
          //$display_row = null;
          foreach ($totalrecord as $row) {
          $a = $row-&gt;token;
          $this-&gt;sendPushNotification($a, $message);
  
              }
          } 
       } 
  
  function get_allrecord(){
    global $wpdb;
    $results =$wpdb-&gt;get_results('SELECT token FROM wp_push_tokens ', OBJECT);
    return $results;
    }
  
   function sendPushNotification($registration_ids, $message) {
      $apiKey = "xxxxxxxxxxxxxxxxxxxxxxx";
       $headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" .   $apiKey);
       $fields = array(
          'register' =&gt;$registration_ids,
          'data' =&gt;$message  );
  
       $ch = curl_init();
  // Set the url, number of POST vars, POST data
  
  curl_setopt($ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send");
  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, wp_json_encode($fields));
  // Execute post
  $result = curl_exec($ch);
     if($result === false)
          die('Curl failed ' . curl_error());
  // Close connection
  curl_close($ch);
  return $result;
  </code></pre>
  
  <p>}</p>