Resource Definitions:Contacts

From API Documentation

Revision as of 16:04, 17 July 2010 by WikiSysop (Talk | contribs)
Jump to: navigation, search

<?php // Set some universal configuration variables. These will be // the same for all your API requests for a particular account. $strUsername = 'hmorgan'; $strPassword = 'd7720f94da2080e4168ed2664356b8ba1ffbfb17'; $strBaseURI = 'http://api.rezora.com/v1/';

// Set some configuration variables specific to the task at hand. // In this example, we'll be posting data to the contacts collection // resource to create a new contact. We'll retrieve the data in text format. $strResourcePath = 'contacts.xml'; $strRequestFormat = 'text/plain'; $strResponseFormat = 'text/plain'; $arrData = array( 'contact_name' => 'API Test', 'contact_email' => 'apitest@rezora.com', 'contact_type' => , 'contact_title' => , 'contact_company' => , 'contact_phone_home' => , 'contact_phone_work' => , 'contact_phone_mobile' => , 'contact_phone_fax' => , 'contact_business_street' => , 'contact_business_street2' => , 'contact_business_city' => , 'contact_business_state' => , 'contact_business_zip' => , 'contact_home_street' => , 'contact_home_street2' => , 'contact_home_city' => , 'contact_home_state' => , 'contact_home_zip' => );


// Create an instance of the RestMakeRequest. $objRequest = new RestMakeRequest($strBaseURI . $strResourcePath, $strMethod, $arrData);

// Open a cURL resource $ch = curl_init();

// Set the necessary parameters curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_setopt($ch, CURLOPT_USERPWD, $strUsername . ':' . $strPassword); curl_setopt($ch, CURLOPT_URL, $strBaseURI . $strResourcePath); curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $strResponseFormat, 'Content-type: ' . $strRequestFormat)); curl_setopt($ch, CURLOPT_POSTFIELDS, $strData); curl_setopt($ch, CURLOPT_POST, 1);

// Make the request and output the response. echo curl_exec($ch);

// Close the cURL resource curl_close($ch); ?>

Personal tools