问题
...
file_get_contents("https://api.weixin.qq.com/sns/jscode2session?appid={$this->appid}&secret={$this->secret}&js_code={$wx_code}&grant_type=authorization_code");
$wx_resp = json_decode($bac);
...

解决
1.确认 php.ini 中, ca 证书的路径正确配置。
2.参考 php 官方文档说明

将问题代码改成:
@file_get_contents("https://api.weixin.qq.com/sns/jscode2session?appid={$this->appid}&secret={$this->secret}&js_code={$wx_code}&grant_type=authorization_code");
$wx_resp = json_decode($bac);
前面加一个 @。
本文详细解答了在使用PHP通过file_get_contents获取微信API授权时遇到的问题,包括检查php.ini中ca证书配置,以及提供了解决代码中特定问题的建议,如在不安全请求前添加 '@' 符号以防止错误输出。

1024

被折叠的 条评论
为什么被折叠?



