我无法从php中获得curl的响应。这是我的代码
$ch = curl_init();
$header = array('api_key:xxxxxxxxxxxxxxxxxxxxxxx','Content-Type: application/json');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
if($postdata!=""){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
}
$response = curl_exec($ch);
print_r($response); // display only 1(one) output not any json
curl_close($ch);
答案 0 :(得分:0)
你在这里输错了
sc.textFile("abc.txt")
您的变量是curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
。那是对的:
$ch