您好,我正在用 php 为 c2dm 编写代码,这是 drupal 模块中的代码,我的问题是它在我的本地主机“wamp”服务器上工作,但是当尝试在我的 centos 5 服务器上使用它时,var_dump($response)返回 bool(false),我的域已通过认证,并且 curl 在我的服务器上运行良好,我的情况有什么解决方案吗?
function push_notifications_c2dm_token() {
$data = array(
'Email' => PUSH_NOTIFICATIONS_C2DM_USERNAME,
'Passwd' => PUSH_NOTIFICATIONS_C2DM_PASSWORD,
'accountType' => 'HOSTED_OR_GOOGLE',
'source' => 'Company-AppName-Version',
'service' => 'ac2dm',
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, PUSH_NOTIFICATIONS_C2DM_CLIENT_LOGIN_ACTION_URL);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
var_dump($response); die();
curl_close($curl);
// Get the auth token.
preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches);
$auth_token = $matches[1];
if (!$auth_token) {
watchdog('push_notifications', 'Google C2DM Server did not provide an authentication token.', NULL, WATCHDOG_ERROR);
}
else {
return $auth_token;
}
}