我無法從fullcontact API批量請求數據。收到的響應是使用以下代碼的「無效查詢對象」:如何在PHP中使用FullContactAPI的批量請求POST請求?
$urltopost = "https://api.fullcontact.com/v2/batch.json?apiKey=xxxxxxxxxx";
$datatopost = array (
"requests" => '["https://api.fullcontact.com/v2/[email protected]","htps://api.fullcontact.com/v2/[email protected]"]'
);
$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/[email protected]","https://api.fullcontact.com/v2/[email protected]"]}' --header 'content-type:application/json'
但我不想從PHP調用shell_exec來做到這一點。我想讓cURL函數起作用。出了什麼問題?
感謝Danny的編輯幫助。一段時間以來,我對這個問題非常嚴重。 –
以下是提供Post請求示例的鏈接。 http://www.fullcontact.com/developer/docs/batch/ –