2012-05-01 27 views
0

你好我正在寫一個代碼爲c2dm與PHP這是在Drupal模塊的代碼,我的問題是它在我的localhost「wamp」服務器上工作,但是當嘗試在我的centos上使用它時5服務器,var_dump($ response)返回bool(false),我的域名已經過認證,curl在我的服務器上運行良好,有沒有針對我的情況的解決方案?php c2dm代碼錯誤的迴應

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

回答

1

你可以使用curl_error()http://www.php.net/manual/en/function.curl-error.php)找到你的代碼的問題。由curl_exec()返回的假布爾值不能提供足夠的信息來解決問題。

+0

謝謝我使用這個命令,這是錯誤「協議https不支持或禁用libcurl」我怎麼能修復它 –

+0

如果centos 5服務器是一個vps或專用服務器,你可以完全管理你必須啓用https協議在libcurl php庫中。我不知道如何做到這一點,我認爲谷歌可以幫助你;) –

+0

它的專用服務器,我會谷歌它謝謝你把我以正確的方式:) –