Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // API access key from Google API's Console
- define( 'API_ACCESS_KEY', 'AIzaSyABatDdUQDzcfY3Nc-vBuvRvMlmPvwNpVs' );
- $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.
- // Modify payload here
- $msg = array
- (
- 'mesgTitle' => 'TheseCounts',
- 'alert' => 'Testing mesg 123'
- );
- $fields = array
- (
- 'registration_ids' => $registrationIds,
- 'data' => $msg
- );
- $headers = array
- (
- 'Authorization: key=' . API_ACCESS_KEY,
- 'Content-Type: application/json'
- );
- $ch = curl_init();
- curl_setopt( $ch,CURLOPT_URL, 'https://gcm-http.googleapis.com/gcm/send' );
- curl_setopt( $ch,CURLOPT_POST, true );
- curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
- curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
- curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
- curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
- $result = curl_exec($ch );
- curl_close( $ch );
- echo $result;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement