1 回答
TA贡献1895条经验 获得超7个赞
问题在于 curl_setopt。您需要为此方法 curl_setopt 传递三个参数(资源 $ch 、 int $option 、混合 $value )。您可以通过以下方式设置这些
$curl = curl_init();
$opts = array (
CURLOPT_URL => 'https://hooks.zapier.com/hooks/catch/',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $dataEncode,
CURLOPT_HTTPHEADER => array (
'Content-type: application/json'
)
);
foreach ($opts as $key => $value) {
curl_setopt($curl, $key, $value);
}
$results = curl_exec($curl);
echo $results;
curl_close($curl);
或者您可以像这样单独设置它们
curl_setopt($curl, CURLOPT_URL, 'https://hooks.zapier.com/hooks/catch/');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
.....
- 1 回答
- 0 关注
- 282 浏览
添加回答
举报