key = $conf['ins_api_key']; $this->sk = $conf['ins_api_sk']; $this->host = 'https://stablediffusionapi.com/api/v3/'; if(!$this->key){ $this->setError('接口参数未正确配置'); } } /** * POST 请求 * @param string $url * @param array $param * @param boolean $post_file 是否文件上传 * @return string content */ private function http_post($url, $param, $jsonpost = false, $post_file = 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 } $httpHeaders = array("Content-Type:application/json"); curl_setopt($oCurl, CURLOPT_URL, $url); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($oCurl, CURLOPT_POST, true); curl_setopt($oCurl, CURLOPT_HTTPHEADER, $httpHeaders); curl_setopt($oCurl, CURLOPT_POSTFIELDS, json_encode($param)); $sContent = curl_exec($oCurl); $sContent = json_decode($sContent,true); $aStatus = curl_getinfo($oCurl); curl_close($oCurl); return $sContent; if ($sContent["status"] == 200) { return $sContent; } else { return false; } } }