Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //OJO. Descomenta si quieres saber donde estan los ficheros libreria
- /*echo("Library path: " . get_include_path() .
- PATH_SEPARATOR .
- realpath(dirname(__FILE__) . "/../../../library") .
- PATH_SEPARATOR .
- realpath(dirname(__FILE__) . "/../../../../../")
- );*/
- 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';
- $message = new Zend_Mobile_Push_Message_Gcm();
- $message->addToken('MY_REGISTRATION');
- $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());
- }
- function sendPush(){
- $message = new Zend_Mobile_Push_Message_Gcm();
- $message->addToken('MY_Registration');
- $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();
- print_r($response);
- }
- ?>
- <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
- <input type="submit" name="escuchar" value="Escuchar">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement