Advertisement
vergepuppeter

GCM Thesecounts

Mar 22nd, 2016
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2. // API access key from Google API's Console
  3. define( 'API_ACCESS_KEY', 'AIzaSyABatDdUQDzcfY3Nc-vBuvRvMlmPvwNpVs' );
  4. $registrationIds = array( 'fDTRCniCGVo:APA91bF_68UtQ96pFmXJkEz4Nhz1xbox4wI-HU0LYTrQ1IX-P2M27M77-yzuKjD-JV1-J9XySiRwwNLSyOxULG_NxC8HsogVz3FvGATfnwe2KhObvGHL7wtGxcH7yq-T3tQYPh2QAmdE' ); //Replace this with your device token. Open any android file manager, check on gcm_smart.txt file.
  5.  
  6.  
  7. // Modify payload here
  8. $msg = array
  9. (
  10.             'mesgTitle'     => 'TheseCounts',
  11.             'alert'         => 'Testing mesg 123'
  12.                
  13. );
  14. $fields = array
  15. (
  16.         'registration_ids'      => $registrationIds,
  17.         'data'                  => $msg
  18. );
  19.  
  20. $headers = array
  21. (
  22.         'Authorization: key=' . API_ACCESS_KEY,
  23.         'Content-Type: application/json'
  24. );
  25.  
  26. $ch = curl_init();
  27. curl_setopt( $ch,CURLOPT_URL, 'https://gcm-http.googleapis.com/gcm/send' );
  28. curl_setopt( $ch,CURLOPT_POST, true );
  29. curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
  30. curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
  31. curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
  32. curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
  33. $result = curl_exec($ch );
  34. curl_close( $ch );
  35. echo $result;
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement