my code

Snippet options

Download: Download snippet as cgm.php.
Copy snippet: For this you need a free my code account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

 $url = '';
 $serverApiKey = "AIzaSyAAUvdtRjyrY4zzmyG_mdTyrBkslBVxDcQ";
 $reg = "APA91bHTSuq_pGZYy9fAIR7GvfH5pqKzq3r6Rux0SGJqDzKoIVLVnrV86pC5rBUPkllF4g6ZKdtJDAc4JkrVAMik0t0t0Uom9fQcN0XvIO5O8gBxWu_OiS-JgNzLQhryNhSNxcXgMjUMYb3B4FD3r1MRFNuwJdS6fQ";

$headers = array(
 'Authorization:key=' . $serverApiKey

 $data = array(
 'registration_ids' => array($reg)
 , 'data' => array(
 'type' => 'New'
 , 'title' => 'GCM'
 , 'msg' => 'Here we completed GCM demo.'
 , 'url' => ''

function do_post_request($url, $data, $optional_headers = null)
  $params = array('http' => array(
              'method' => 'POST',
              'content' => $data
  if ($optional_headers !== null) {
    $params['http']['header'] = $optional_headers;
  $ctx = stream_context_create($params);
  $fp = @fopen($url, 'rb', false, $ctx);
  if (!$fp) 
    throw new Exception("Problem with $url, $php_errormsg");
  $response = @stream_get_contents($fp);
  if ($response === false) {
    throw new Exception("Problem reading data from $url, $php_errormsg");
  return $response;

Create a free my code account now.

my code is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.