I use the following script to update a contact, but the server halts. It stays at "waiting for..." no error shown or displayed in over 2 minutes.
the URI is: http://api.constantcontact.com/ws/customers/coaliconsur/contacts/489
** note : removed $content var because not showing correctly.Published at : http://www.coalicionsur.org/wp-content/themes/revolution_business-10/scr... // use view source
Can someone point me what I am doing wrong,
thanks
<?php
require "Constants.php";
//echo $_POST[uri];
$request = $_POST[uri];
// Initialize the session
$session = curl_init($request);
// Set up Digest authentication - username and password.
$userNamePassword = $_POST[PARAM_NAME_API_KEY] . '%' . $_POST[PARAM_NAME_USER_NAME] . ':' . $_POST[PARAM_NAME_PASSWORD];
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type: application/atom+xml'));
curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);
curl_setopt($session, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($session, CURLOPT_PUT, 1);
curl_setopt($session, CURLOPT_INFILE, $content);
curl_setopt($session, CURLOPT_INFILESIZE, strlen($content));
curl_setopt($session, CURLOPT_HEADER, 0); // Do not return headers
// The following option tells Curl to not send the result of the execution to the browser
// This must be set to 1 or true in order to process the resulting xml programatically.
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); // return contents of the call, do not push to the browser
// Make the request
$response = curl_exec($session);
// Close the curl session
curl_close($session);
echo $response;
?>
contact update php
please try replacing these lines in your code
curl_setopt($session, CURLOPT_INFILE, $content);
curl_setopt($session, CURLOPT_INFILESIZE, strlen($content));
with this line of code
curl_setopt($session, CURLOPT_POSTFIELDS , $content);