ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
示例: ~~~ $header = array( "Content-Type: application/x-www-form-urlencoded" ); //联调环境加入cookie /* $header= array_push($header,"Cookie: access_log=2835d31abae4b46fa2d28458a16daebf; Hm_lvt_a028c07bf31ffce4b2d21dd85b0b8907=1462262091; BDUSS=5LdmgzanEzZWdJWHNnd3dia2RQSVJ1QmVSUXl-R3RBcTNFTmZlbUR0ZloxRDlYQVFBQUFBJCQAAAAAAAAAAAEAAABb40YV1rvX7b32w9QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANlHGFfZRxhXNE; BAIDUID=4902995690F7DBDFA03E52EB588475E4:FG=1; SITE_CODE_TICKET=8F62515AD573A8381A3AD2145416CCBC; SITE_CODE_AK=7692631; Hm_lvt_96fdc2cf90dc42fbdd3eb4187e18b247=1463467503; areaCode=100010000; CNZZDATA1256793290=1926708081-1463461684-%7C1463639937; JSESSIONID=946D8F12CC7EF41DF5E6B457C52DC6E4");*/ private static function http_post($url, $param, $header = false) { $oCurl = curl_init(); if (stripos($url, "https://") !== FALSE) { curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1 } if (is_string($param)) { $strPOST = $param; } else { $aPOST = array(); foreach ($param as $key => $val) { $aPOST[] = $key . "=" . urlencode($val); } $strPOST = join("&", $aPOST); } if ($header) { curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header); } curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($oCurl, CURLOPT_POST, true); curl_setopt($oCurl, CURLOPT_POSTFIELDS, $strPOST); self::writelog('request:'.$strPOST,'request.txt'); $sContent = curl_exec($oCurl); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); if (intval($aStatus["http_code"]) == 200) { return $sContent; } else { return false; } } ~~~