curl来实现iphone远程通知的服务器端

时间:2022-11-23 17:57:29
  1. $curl = curl_init();
  2. curl_setopt($curl, CURLOPT_URL, $ssl_url);
  3. curl_setopt($curl, CURLOPT_POST, 1);

  4. curl_setopt($curl, CURLOPT_SSLCERT, realpath("cert.pem"));//证书
  5. curl_setopt($curl, CURLOPT_SSLCERTPASSWD,'');
  6. curl_setopt($curl, CURLOPT_SSLKEY,realpath("key.pem"));//私钥
  7. curl_setopt($curl, CURLOPT_SSLKEYPASSWD, $pass);

  8. //curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,2);
  9. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  10. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  11. curl_setopt($curl, CURLOPTL_HTTPAUTH, CURLAUTH_BASIC);
  12. curl_setopt($curl, CURLOPT_POSTFIELDS, $msg);
  13. $data = curl_exec($curl);
  14. echo "error: ".curl_error($curl)."<br>";
  15. echo "errno: ".curl_errno($curl);
  16. curl_close($curl);
  17. //var_dump($data);
  18. echo "<br>return curl data: ".$data;