php 发送https请求


最近遇到一个新的需求,是关于https接口的, 目标接口是https, 客户端使用php开发, 我对https方面的知识还不太了解, 所以请教各位:
1.如果服务器端使用https,需要安装哪些软件?(web服务器是apache)
2.客户端需要哪些软件?
3.证书只在服务器端,还是也得装到客户端?
4.使用php如何发起https的get请求?

php https

78164 12 years, 3 months ago

用cURL

   
  $ch = curl_init();
  
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "field1=".$f1."&field2=".$f2."&SomeFlag=True");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/Library/WebServer/Documents/tmp/cookieFileName");
curl_setopt($ch, CURLOPT_URL,"https://www.example.com/myaccount/Login.asp");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec ($ch);
curl_close ($ch);

今夜扮作大灰狼 answered 12 years, 3 months ago

Your Answer