请问,弹性WEB托管,我在本地服务器上测试正常,但上传到弹性WEB托管服务器后,发现PHP CURL功能用不了。错误信息如下:
error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
然后我用阿里云提供的测试样例程序测试,程序代码如下:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=wxf6572b80d4236dd82347c&corpsecret=4j46JIVgBm_kpwiOpzmOdn7S9yegVygjrUcwpvgYnoICbAJj1w9OxHjNGYBo9HWgsdf");
curl_setopt($ch, CURLOPT_HEADER, false);
#curl_setopt($ch, CURLOPT_TIMEOUT_MS, 30);
#curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 10000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
echo $response."
".$curl_error ;
?>
本地执行提示以下错误信息:
SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
上传到阿里云弹性服务器,提示如下错误信息:
error setting certificate verify locations: CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
附我个人的部分程序代码:
<?php
//调用微信企业号接口发送通报信息的PHP代码
function curlPost($url,$data="")
{
$ch = curl_init();
$opt = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => 20
);
$ssl = substr($url,0,8) == "https://" ? TRUE : FALSE;
if ($ssl){
$opt[CURLOPT_SSL_VERIFYHOST] = 1;
$opt[CURLOPT_SSL_VERIFYPEER] = FALSE;
}
curl_setopt_array($ch,$opt);
$data = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
echo $curl_error;
curl_close($ch);
return $data;
}
/*
Call to undefined function curl_init
解决方法如下:
1.打开php.ini,开启extension=php_curl.dll
2.检查php.ini的extension_dir值是哪个目录,检查有无php_curl.dll,没有的请下载php_curl.dll,再把php目录中的libeay32.dll,ssleay32.dll拷到c:windowssystem32里面
修改之后还有问题啊
在httpd.conf文件中加上:
LoadFile 动态链接库的完整路径
比如,此处php需要扩展curl,因此解决方法就是在httpd.conf文件中加上:
LoadFile C:/Apache2.2/php-5.2.1/libeay32.dll
LoadFile C:/Apache2.2/php-5.2.1/ssleay32.dll
这样就解决了
*/
function wx_send($touser,$topart,$totag,$msgtype,$agentid,$msg,$safe,$corpid,$corpsecret)
{
$corpid="wxf6572b80d4236dd82347c";
$corpsecret="4j46JIVgBm_kpwiOpzmOdn7S9yegVygjrUcwpvgYnoICbAJj1w9OxHjNGY234Bo9HWg";
$Url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
$res = curlPost($Url);
$ACCESS_TOKEN=json_decode($res)->access_token;
$Url="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$ACCESS_TOKEN";
$msg=iconv('gb2312', 'UTF-8//IGNORE', $msg); //微信用的是UTF-8,所以编码要一致。
$data="{\"touser\":\"$touser","topart":"$topart\",\"totag\":\"$totag","msgtype":"$msgtype\",\"agentid\":$agentid,"text":{"content":"$msg\"},\"safe\":$safe}";
$res = curlPost($Url,$data);
$errmsg=json_decode($res)->errmsg;
return($errmsg);
}
?>
以上情况是什么原因,请求支持! tkt1020@163.com
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。