Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php GCM can';在新环境中定位后是否不发送消息?_Php_Html_Google Cloud Messaging - Fatal编程技术网

Php GCM can';在新环境中定位后是否不发送消息?

Php GCM can';在新环境中定位后是否不发送消息?,php,html,google-cloud-messaging,Php,Html,Google Cloud Messaging,我在localhost中使用了GCM,一切都很好,可以从设备发送和接收消息,但当我将所有文件(php)从localhost(我在本地PC上使用php5.3.8,Windows 7)移动到VPS(ubuntu 12.04上的php5.3.10-1)时,我无法再发送了 我不明白发生了什么? 这里是我的GCM文件代码 <?php class GCM { //put your code here // constructor function __construct()

我在localhost中使用了GCM,一切都很好,可以从设备发送和接收消息,但当我将所有文件(php)从localhost(我在本地PC上使用php5.3.8,Windows 7)移动到VPS(ubuntu 12.04上的php5.3.10-1)时,我无法再发送了

我不明白发生了什么? 这里是我的GCM文件代码

<?php
class GCM {

    //put your code here
    // constructor
    function __construct() {

    }

    /**
     * Sending Push Notification
     */
    public function send_notification($registatoin_ids, $message) {
        // include config
        include_once './config.php';

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

        $fields = array(
            'registration_ids' => $registatoin_ids,
            'data' => $message,
        );

        $headers = array(
            'Authorization: key=' . GOOGLE_API_KEY,
            'Content-Type: application/json'
        );
        // Open connection
        $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) {
            die('Curl failed: ' . curl_error($ch));
        }

        // Close connection
        curl_close($ch);
        echo $result;
    }

}

?>

我认为我在这个文件中遇到了问题,因为我无法从GCM类获得任何返回值。但是为什么呢?也许我的php版本已经改变了