Skip to content

Instantly share code, notes, and snippets.

@LeeXun
Forked from prime31/gist:5675017
Created July 21, 2016 09:29
Show Gist options
  • Save LeeXun/f068e5411a57aed6153f3f349bafefe0 to your computer and use it in GitHub Desktop.
Save LeeXun/f068e5411a57aed6153f3f349bafefe0 to your computer and use it in GitHub Desktop.

Revisions

  1. @prime31 prime31 revised this gist Sep 16, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@
    // prep the bundle
    $msg = array
    (
    'message' => 'here is a message. message',
    'message' => 'here is a message. message',
    'title' => 'This is a title. title',
    'subtitle' => 'This is a subtitle. subtitle',
    'tickerText' => 'Ticker text here...Ticker text here...Ticker text here',
  2. @prime31 prime31 revised this gist Sep 16, 2014. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -10,17 +10,19 @@
    $msg = array
    (
    'message' => 'here is a message. message',
    'title' => 'This is a title. title',
    'subtitle' => 'This is a subtitle. subtitle',
    'title' => 'This is a title. title',
    'subtitle' => 'This is a subtitle. subtitle',
    'tickerText' => 'Ticker text here...Ticker text here...Ticker text here',
    'vibrate' => 1,
    'sound' => 1
    'sound' => 1,
    'largeIcon' => 'large_icon',
    'smallIcon' => 'small_icon'
    );

    $fields = array
    (
    'registration_ids' => $registrationIds,
    'data' => $msg
    'data' => $msg
    );

    $headers = array
  3. @prime31 prime31 revised this gist Aug 30, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,9 @@
    'message' => 'here is a message. message',
    'title' => 'This is a title. title',
    'subtitle' => 'This is a subtitle. subtitle',
    'tickerText' => 'Ticker text here...Ticker text here...Ticker text here'
    'tickerText' => 'Ticker text here...Ticker text here...Ticker text here',
    'vibrate' => 1,
    'sound' => 1
    );

    $fields = array
  4. @prime31 prime31 created this gist May 30, 2013.
    40 changes: 40 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    <?php

    // API access key from Google API's Console
    define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );


    $registrationIds = array( $_GET['id'] );

    // prep the bundle
    $msg = array
    (
    'message' => 'here is a message. message',
    'title' => 'This is a title. title',
    'subtitle' => 'This is a subtitle. subtitle',
    'tickerText' => 'Ticker text here...Ticker text here...Ticker text here'
    );

    $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://android.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;