I am having trouble converting command line cURL to php cURL. I have read the other links on this topic, and am still stuck, and would appreciate any help.
I am trying to automatically put contact info from a web form into an online CRM.
API info: http://karmacrm.zendesk.com/entries/23648323-Contacts
My Code:
$header = array('contact[first_name]=aaaaaaa','API-KEY: XXXXXXXXX');
$pageurl = "https://app.karmacrm.com/api/v2/contacts.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $pageurl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_USERPWD, '[email protected]:7iNXXXXXXXXXX');
curl_setopt($ch, CURLOPT_HEADER, TRUE); // -i
curl_setopt($ch, CURLOPT_VERBOSE, TRUE); // -v
curl_setopt($ch, CURLOPT_CUSTOMEREQUEST, "POST"); //-X
curl_setopt($ch, CURLOPT_BINARYTRANSFER, FALSE); // --data-binary, -d
$output = curl_exec($ch); 
curl_close($ch);
echo $output;
The Response:
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8 
Transfer-Encoding: chunked 
Connection: keep-alive 
Status: 401 
X-Powered-By: Phusion Passenger (mod_rails/mod_rack) 3.0.11 
Strict-Transport-Security: max-age=31536000 
X-UA-Compatible: IE=Edge,chrome=1 
Cache-Control: no-cache, private 
X-Request-Id: 8d9397e1c2d43580db7XXXXXXXXXXXX 
X-Runtime: 0.004153 
Date: Wed, 24 Apr 2013 03:14:27 GMT 
X-Rack-Cache: miss 
Server: nginx/1.2.3 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
{"error":"You need to sign in or sign up before continuing."}1
Thanks for any help, I appreciate it.