- Jun 16, 2010
- 991
- 131
I can't get this to post, I am trying to update a customer record with a new phone number. What is wrong with my code below?
PHP:
// API URL
$url = "https://openapi.api.com/api/v2/open/customers/10005182";
// Create a new cURL Resource
$curl = curl_init($url);
// Setup request to send json via POST
$data = array(
"Phone" => "7656493111"
);
$data = json_encode(array($data));
// Attach encoded JSON string to the POST fields
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
// Set the content type to application/json
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Authorization: ApiKey DEMO', 'Content-Type:application/json'));
// Return response instead of outputting
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
$resp = curl_exec($curl);
print_r($resp);