Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_include_path(get_include_path() .
- PATH_SEPARATOR .
- realpath(dirname(__FILE__) . "/../../../library") .
- PATH_SEPARATOR .
- realpath(dirname(__FILE__) . "/../../../../../")
- );
- require_once 'Zend/Mobile/Push/Gcm.php';
- require_once 'Zend/Mobile/Push/Message/Gcm.php';
- function sendPush($registrationId) {
- $message = new Zend_Mobile_Push_Message_Gcm();
- $message->addToken($registrationId);
- $message->setData(array(
- 'foo' => 'bar',
- 'bar' => 'foo',
- ));
- $gcm = new Zend_Mobile_Push_Gcm();
- $gcm->setApiKey('MY_API_KEY');
- try {
- $response = $gcm->send($message);
- } catch (Zend_Mobile_Push_Exception $e) {
- // exceptions require action or implementation of exponential backoff.
- die($e->getMessage());
- }
- return $response;
- }
- if(isset($_POST["escuchar"])) {
- $response = sendPush($_POST['registration_id']);
- print_r($response);
- }
- ?>
- <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
- <input type="text" name="registration_id" />
- <input type="submit" name="escuchar" value="Escuchar">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement