Login   Register  
PHP Classes
elePHPant
Icontem

File: testPush.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Christiaan Baartse  >  PHP Google Cloud Messaging Server  >  testPush.php  >  Download  
File: testPush.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Google Cloud Messaging Server
Send messages to Android applications using GCM
Author: By
Last change:
Date: 2013-02-26 03:31
Size: 494 bytes
 

Contents

Class file image Download
<?php
include 'vendor/autoload.php';

class 
EchoLogger extends \Psr\Log\AbstractLogger
{
    public function 
log($level$message, array $context = array())
    {
        echo 
sprintf('%s: %s'.PHP_EOL$level$message);
    }
}

$sender = new \WebPower\gcm\server\Sender('api key');
$sender->setLogger(new EchoLogger());

$message = \WebPower\gcm\server\Message::builder();
$message->addData('message''Hoi');

$result $sender->singleSendNoRetry($message->build(), 'reg Id');

echo 
$result;