调用阿里云云市场 如果是中文转义

    public function dream($keyword)
{
$host = "https://jisudream.market.alicloudapi.com";
$path = "/dream/search";
$method = "GET";
$appcode = self::$dream_appcode;
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
//根据API的要求,定义相对应的Content-Type
array_push($headers, "Content-Type" . ":" . "application/json; charset=UTF-8");
$querys = [
'keyword' => trim($keyword)
];
$querys = http_build_query($querys);
$bodys = "null";
$url = $host . $path . "?" . $querys;
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
// curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$" . $host, "https://")) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
$T = curl_exec($curl);
var_dump($T);exit();
return $T;
}
posted @ 2022-08-12 09:36  zlf2000  阅读(31)  评论(0编辑  收藏  举报