0

Hello there i'm writing a code for c2dm with php this is the code in drupal module, my problem is it is working on my localhost "wamp" server but when try using it on my centos 5 server, the var_dump($response) returns bool(false), my domain is certified and curl is working well on my server, is there any solution for my case?

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;
  }
}
se_bastiaan
  • 1,716
  • 14
  • 19

1 Answers1

1

You could use curl_error() (http://www.php.net/manual/en/function.curl-error.php) to find the problem in your code. The false boolean returned by the curl_exec() is not giving enough information to solve the problem.

se_bastiaan
  • 1,716
  • 14
  • 19
  • Thanks i use this command and this is the error "Protocol https not supported or disabled in libcurl" how can i fix it – Yousef Abu Samak May 01 '12 at 15:21
  • If the centos 5 server is a vps or dedicated server you can totally manage you have to enable the https protocol in the libcurl php library. I don't know how to do this, I think Google could help you ;) – se_bastiaan May 01 '12 at 15:29
  • its dedicated server and i will google it thanks you put me in the right way :) – Yousef Abu Samak May 01 '12 at 15:36