Constant Contact API, Adding a new contact -


i trying add new email subscriber contact contact list. getting 404 error. following code. can help?

$usernamepassword = $key . '%' . $un . ':' . $pw ;  $entry = '<entry xmlns="http://www.w3.org/2005/atom"> <id>http://api.constantcontact.com/ws/customers/'.$un.'/contacts/'.$subid.'</id>         <title type="text">contact: '.$email.'</title>         <updated>2008-04-25t19:29:06.096z</updated>         <author></author>         <content type="application/vnd.ctct+xml">         <contact xmlns="http://ws.constantcontact.com/ns/1.0/"     id="http://api.constantcontact.com/ws/customers/'.$un.'/contacts/'.$subid.'">         <emailaddress>'.$email.'</emailaddress>         <optinsource>action_by_customer</optinsource>         <contactlists>         <contactlist id="http://api.constantcontact.com/ws/customers/'.$un.'/lists/0">         </contactlists>         </contact>         </content>         </entry>';           $tmpfile = tmpfile();        fwrite($tmpfile, $entry);        fseek($tmpfile, 0);         // initialize curl session        $request ="https://api.constantcontact.com/ws/customers/".$un."/contacts/".$subid;         $session = curl_init($request);         // set digest authentication. put api key, , ctct username/pwd here        $usernamepassword = $key . '%' . $un . ':' . $pw ;         curl_setopt($session, curlopt_httpauth, curlauth_basic);        curl_setopt($session, curlopt_userpwd, $usernamepassword);        curl_setopt($session, curlopt_infile, $tmpfile);        fclose($tmpfile); // close temp file because no longer needed         curl_setopt($session, curlopt_put, 1);        curl_setopt($session, curlopt_infilesize, strlen($entry));        curl_setopt($session, curlopt_httpheader, array("content-type:application/atom+xml"));        curl_setopt($session, curlopt_header, false);   // not return headers         curl_setopt($session, curlopt_returntransfer, 0);        curl_setopt($session, curlopt_ssl_verifypeer, 0);        $response = curl_exec($session);        $httpcode = curl_getinfo($session, curlinfo_http_code);        curl_close($session);           echo("httpcode error ".$httpcode);          if ($httpcode > 199 && $httpcode < 300){              return 'success';          }else{              return 'false';         } 

ok, able resolve issue making post. i.e, replaced following code

curl_setopt($session, curlopt_put, 1); 

with following codes

curl_setopt($session, curlopt_post, 1); curl_setopt($session, curlopt_postfields, $entry); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -