美文网首页
GCM推送测试

GCM推送测试

作者: riane | 来源:发表于2017-08-20 18:13 被阅读0次

    array( $reg_id),

    'data'              => $message,

    );

    $headers = array(

    'Authorization: key=' . GOOGLE_API_KEY,

    'Content-Type: application/json'

    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, GOOGLE_GCM_URL);

    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);

    if ($result === FALSE) {

    die('Problem occurred: ' . curl_error($ch));

    }

    curl_close($ch);

    echo $result;

    }

    //$reg_id = "APA91bHzR8AKUC07N11MynfjMPLflQmUSUJiwHLwQlNq7vfuWSIwHhQpNkKYLA3ex1-f-FlpgO7KiYF617cEXjWvqVQAdXGRA0fuGFJnGcsqXTqEka_qNBPbWsPEqVTztFhL9JN0-cxq";

    $reg_id = "APA91bHIcwXvmhYP8XJ16WY9f4tXXP_ImwfMU5f6rKOSdtdlaPqWpG4gB4sv1iB6fCLFeW6L5njutCrFK22a6rdN5EYtebBYBJwMs6anbgU1xcL2yib5-jRm_sXZ9LfuKMMtVzDoXaDq";

    //$msg = "Google Cloud Messaging working well";

    $msg = array("gcm.notification.parameters" => array("pictureUrl"=>"http://www.nfanr.com/dice/icon.png"),

    "gcm.notification.tickerText" => "s",

    "gcm.notification.contentTitle" => "ddd",

    "gcm.notification.contentText" => "ddd",

    "gcm.notification.id" => 1);

    send_gcm_notify($reg_id, $msg);

    相关文章

      网友评论

          本文标题:GCM推送测试

          本文链接:https://www.haomeiwen.com/subject/wxofdxtx.html