php SSL certificate problem: unable to get local issuer certificate
加上
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
就可以了
百度语音的demo:
<?php header("Content-type:audio/mp3; charset=utf-8"); //put your params here $cuid = "9619439"; $apiKey = "gSwM3lYXkKXp5dDuU6zBjHrr"; $secretKey = "ff9c651db48ac780c85eed057c593e89"; $auth_url = "https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=".$apiKey."&client_secret=".$secretKey; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $auth_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); $response = curl_exec($ch); if(curl_errno($ch)) { print curl_error($ch); } curl_close($ch); $response = json_decode($response, true); $token = $response['access_token']; function double ($a) { return urlencode(urlencode($a)); } $url = "http://tsn.baidu.com/text2audio?tex=".double('123')."&lan=".double('zh')."&cuid=".double($cuid)."&ctp=".double('1')."&tok=".double($token); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); $response = curl_exec($ch); if(curl_errno($ch)) { print curl_error($ch); } curl_close($ch); echo $response; $response = json_decode($response, true); var_dump($response); ?>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理