Advertisement
Guest User

Untitled

a guest
Jul 8th, 2012
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2. //OJO. Descomenta si quieres saber donde estan los ficheros libreria
  3. /*echo("Library path: " . get_include_path() .
  4. PATH_SEPARATOR .
  5. realpath(dirname(__FILE__) . "/../../../library") .
  6. PATH_SEPARATOR .
  7. realpath(dirname(__FILE__) . "/../../../../../")
  8. );*/
  9.  
  10. set_include_path(get_include_path() .
  11. PATH_SEPARATOR .
  12. realpath(dirname(__FILE__) . "/../../../library") .
  13. PATH_SEPARATOR .
  14. realpath(dirname(__FILE__) . "/../../../../../"));
  15.  
  16.  
  17. require_once 'Zend/Mobile/Push/Gcm.php';
  18. require_once 'Zend/Mobile/Push/Message/Gcm.php';
  19.  
  20.  
  21.  
  22. $message = new Zend_Mobile_Push_Message_Gcm();
  23. $message->addToken('MY_REGISTRATION');
  24. $message->setData(array(
  25. 'foo' => 'bar',
  26. 'bar' => 'foo',
  27. ));
  28.  
  29. $gcm = new Zend_Mobile_Push_Gcm();
  30. $gcm->setApiKey('MY_API_KEY');
  31.  
  32. try {
  33. $response = $gcm->send($message);
  34. } catch (Zend_Mobile_Push_Exception $e) {
  35. // exceptions require action or implementation of exponential backoff.
  36. die($e->getMessage());
  37. }
  38.  
  39. function sendPush(){
  40. $message = new Zend_Mobile_Push_Message_Gcm();
  41. $message->addToken('MY_Registration');
  42. $message->setData(array(
  43. 'foo' => 'bar',
  44. 'bar' => 'foo',
  45. ));
  46.  
  47. $gcm = new Zend_Mobile_Push_Gcm();
  48. $gcm->setApiKey('MY_API_KEY');
  49.  
  50. try {
  51. $response = $gcm->send($message);
  52. } catch (Zend_Mobile_Push_Exception $e) {
  53. // exceptions require action or implementation of exponential backoff.
  54. die($e->getMessage());
  55. }
  56. return $response;
  57. }
  58.  
  59. if(isset($_POST["escuchar"]))
  60. {
  61. $response = sendPush();
  62. print_r($response);
  63. }
  64.  
  65. ?>
  66. <form method="post" action="<?=$_SERVER['PHP_SELF']?>">
  67. <input type="submit" name="escuchar" value="Escuchar">
  68. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement