我有以下PHP代码:
curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_USERAGENT, $this->_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->_headers); curl_setopt($ch, CURLOPT_ENCODING , "gzip"); curl_setopt($ch, CURLOPT_VERBOSE, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->_cookie_file_path); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->_cookie_file_path); curl_setopt($ch, CURLOPT_POSTFIELDS, '{"folderId":"1","parameters":{"amount":3,"ascending":false,"offset":0,"sort":"date"}}'); curl_setopt($ch, CURLOPT_POST, 1);但我不明白为什么它不起作用。我要将JSON发送到的API说参数未被接收。我的代码有问题吗?我认为整个问题在于JSON参数......我不确定该如何发送它们,因为在简单表单中通常不会出现任何“name->value”对,只有没有任何名称的JSON代码。
json_encode
? - mario