view raw
Jigar Bhatt Jigar Bhatt - 7 months ago 57
PHP Question

How to use POST request in PHP with FullContactAPI for Batch Requests?

I am not able to request for data in batch from fullcontact API. The response received is "invalid query object" using the following code:

$urltopost = "";
$datatopost = array (
"requests" => '["","htps://"]'
$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);

Writing the shell execution which worked correctly.

curl --request POST "" --data '{'requests':["",""]}' --header 'content-type:application/json'

But I don't want to call shell_exec from php to do this. I want cURL functions to work. What's going wrong?


Ok. So I think I found my own answer. I just had to change that array into string. And it worked perfectly.

$datatopost = '{"requests":["",""]}';