我无法从 fullcontact API 批量请求数据。使用以下代码收到的响应是“无效的查询对象”:
$urltopost = "https://api.fullcontact.com/v2/batch.json?apiKey=xxxxxxxxxx";
$datatopost = array (
"requests" => '["https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com","htps://api.fullcontact.com/v2/person.json?email=jigarbhatt30893@yahoo.co.in"]'
);
$header=array("content-type"=>"application/json");
$ch = curl_init ($urltopost);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $datatopost);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
$returndata = curl_exec ($ch);
print_r($returndata);
编写正常工作的 shell 执行。
curl --request POST "https://api.fullcontact.com/v2/batch.json?apiKey=xxxxxxxxxx" --data '{'requests':["https://api.fullcontact.com/v2/person.json?email=bart@fullcontact.com","https://api.fullcontact.com/v2/person.json?email=jigarbhatt30893@yahoo.co.in"]}' --header 'content-type:application/json'
但我不想从 php 调用 shell_exec 来执行此操作。我希望 cURL 函数能够工作。怎么了?