什么url可以用来为新的GCM框架实现Http服务器

What url can be used to implement Http server for new GCM framework

我已经在我的项目中实现了用于发送消息的 GCM,它在 7 月 28 日之前工作正常,突然,应用程序开始出现问题。我的 php 应用服务器发送消息的代码示例看起来像

 function setPush_Notification($device_Ids, $message) {
$url = "https://android.googleapis.com/gcm/send";
$GOOGLE_API_KEY = "MY_API_KEY";
$fields = array('registration_ids' => $device_Ids,
    'data' => $message,
);
$headers = array(
    'Authorization: key=' . $GOOGLE_API_KEY,
    'Content-Type: application/json'
);
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

//Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));

// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
    print_r(curl_getinfo($ch));
    die('Curl failed: ' . curl_error($ch));
}
    curl_close($ch);
    return $result;
}

但最近,我无法发送消息,看来问题出在 url,因为每次尝试 returns 都会出现错误:

Failed to connect to 2a00:1450:4016:804::200a: Network is unreachable And i from my findings it's the server https://android.googleapis.com/gcm/send that is unreachable, what url is now used to send messages from thirdparty app servers to GCM ????.

我试过其他 url https://gcm-http.googleapis.com/gcm/send 但没有成功。 还有其他人经历过吗?请帮忙

检查下面的 link 两天前,我已经在我的应用程序中使用它实现了 GCM。它的工作 检查这个 https://developers.google.com/cloud-messaging/android/client

function px_sendGCM($message, $type) {

$result;

$options = get_option('gcm_setting');

$apiKey = $options['api-key'];

$url = 'https://android.googleapis.com/gcm/send';

$id = px_getIds();



if($id >= 1000){

    $newId = array_chunk($id, 1000);

    foreach ($newId as $inner_id) {

        $fields = array(

            'registration_ids' => $inner_id,

            'data' => array( $type => $message ),);

        $headers = array(

            'Authorization: key=' . $apiKey,

            'Content-Type: application/json');



        $ch = curl_init();

        curl_setopt( $ch, CURLOPT_URL, $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);

    }

}else {

    $fields = array(

        'registration_ids' => $id,

        'data' => array( $type => $message ),);

    $headers = array(

        'Authorization: key=' . $apiKey,

        'Content-Type: application/json');



    $ch = curl_init();

    curl_setopt( $ch, CURLOPT_URL, $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);

}



$answer = json_decode($result);

这个是对的URL,根据https://developers.google.com/cloud-messaging/http

https://gcm-http.googleapis.com/gcm/send

如果它也不起作用,请检查您的网络。