I'm trying to post some JSON data in PHP on my local server. I have the following code below but it's not working. Did i miss a vital thing?
<?php
$postRequest = array (
// Every array will be converted
// to an object
array(
"Attribute" => "FirstName",
"Value" => "maheshr"
),
array(
"Attribute" => "LastName",
"Value" => "netha"
),array(
"Attribute" => "EmailAddress",
"Value" => "mahesh3@simandhareducation.com"
),array(
"Attribute" => "Phone",
"Value" => "9553754571"
),
array(
"Attribute" => "Source",
"Value" => "Website"
),
array(
"Attribute" => "SearchBy",
"Value" => "Phone"
),
array(
"Attribute" => "mx_City",
"Value" => "Hyderabad"
) ,
array(
"Attribute" => "mx_Course",
"Value" => "CPA"
)
);
$postRequest = json_encode($postRequest);
// echo $postRequest;
$cURLConnection = curl_init('url');
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $postRequest);
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
$apiResponse = curl_exec($cURLConnection);
curl_close($cURLConnection);
// $apiResponse - available data from the API request
$jsonArrayResponse = json_decode($apiResponse);
echo $jsonArrayResponse;
?>
I am not able to get any response from the curl request. Can anybody help me ?
Thank you.