你好我正在用php编写c2dm的代码这是drupal模块中的代码,我的问题是它在我的localhost“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;
}
}
答案 0 :(得分:1)
您可以使用curl_error()
(http://www.php.net/manual/en/function.curl-error.php)在代码中查找问题。 curl_exec()
返回的假布尔值没有提供足够的信息来解决问题。