PHP-curl传参
2021-03-03 17:29
标签:ima inf timestamp enc tps === tran content code 当传参data为二维数组,Content-Type: application/x-www-form-urlencoded时, $a = array(‘a‘,‘b‘,‘c‘); $a[‘d‘] = array(‘e‘,‘f‘,‘g‘); 传参为二维数组时 $a[‘d‘] = json_encode($a[‘d‘]); $data = http_build_query($data); $this->httpcurl_post($url,$data); private function httpcurl_post($url,$data) { $ch = curl_init(); $header = array( curl_setopt($ch, CURLOPT_HTTPHEADER, $header); // if(substr($url, 0,5) == ‘https‘) { //post提交方式 $rtn = curl_exec($ch); // if($rtn === false) { return $rtn; PHP-curl传参 标签:ima inf timestamp enc tps === tran content code 原文地址:https://www.cnblogs.com/PHP-Jason/p/14252086.html
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
‘Content-Type: application/x-www-form-urlencoded‘,
‘projectId:‘.$this->projectId,
‘secret:‘.$this->do_secret,
‘timestamp:‘.$this->timestamp
);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
// }
curl_setopt($ch, CURLOPT_POST, true);
//curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
// //var_dump(curl_error($ch));exit;
// trigger_error("[CURL_" . curl_errno($ch) . "]: " . curl_error($ch), E_USER_ERROR);
// }
curl_close($ch);
下一篇:Web服务器是什么?