Resource Definitions:Contacts

From API Documentation

(Difference between revisions)
Jump to: navigation, search
(Created page with 'The contacts resource is a collection of all contacts associated with your agent account. Available methods are: == GET == Returns a list of contacts. Each contact record includ…')
Line 1: Line 1:
-
The contacts resource is a collection of all contacts associated with your agent account. Available methods are:
+
<?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/';
-
== GET ==
+
// Set some configuration variables specific to the task at hand.
-
Returns a list of contacts. Each contact record includes the following fields:
+
// 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' => ''
 +
);
-
* contact_id
 
-
* contact_name
 
-
* contact_email
 
-
* 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
 
-
* contact_date
 
-
* contact_self
 
-
=== Example Response - XML ===
+
// Create an instance of the RestMakeRequest.
-
<source lang="xml">
+
$objRequest = new RestMakeRequest($strBaseURI . $strResourcePath, $strMethod, $arrData);
-
<?xml version="1.0" encoding="UTF-8"?>
+
-
<contacts version="1.0">
+
-
<contact>
+
-
  <contact_id>123456</contact_id>
+
-
  <contact_name>Jane Smith</contact_name>
+
-
  <contact_email>jane.smith@company.com</contact_email>
+
-
  <contact_type>Active</contact_type>
+
-
  <contact_title>Consultant</contact_title>
+
-
  <contact_company>Acme Consulting</contact_company>
+
-
  <contact_phone_home>303-555-1234</contact_phone_home>
+
-
  <contact_phone_work>303-555-1235</contact_phone_work>
+
-
  <contact_phone_mobile>303-555-1236</contact_phone_mobile>
+
-
  <contact_phone_fax>303-555-1237</contact_phone_fax>
+
-
  <contact_business_street>123 Church Street</contact_business_street>
+
-
  <contact_business_street2>Suite 12</contact_business_street2>
+
-
  <contact_business_city>Shady Acres</contact_business_city>
+
-
  <contact_business_state>CO</contact_business_state>
+
-
  <contact_business_zip>12345</contact_business_zip>
+
-
  <contact_home_street>124 Church Street</contact_home_street>
+
-
  <contact_home_street2></contact_home_street2>
+
-
  <contact_home_city>Shady Acres</contact_home_city>
+
-
  <contact_home_state>CO</contact_home_state>
+
-
  <contact_home_zip>12345</contact_home_zip>
+
-
  <contact_date>2010-07-16 22:34:01</contact_date>
+
-
  <contact_self>0</contact_self>
+
-
</contact>
+
-
...
+
-
</contacts>
+
-
</source>
+
-
=== Example Response - JSON ===
+
// Open a cURL resource
-
<source lang="javascript">
+
$ch = curl_init();
-
[
+
-
{
+
-
  "contact_id":"123456",
+
-
  "contact_name":"Jane Smith",
+
-
  "contact_email":"jane.smith@company.com",
+
-
  "contact_type":"Active",
+
-
  "contact_title":"Consultant",
+
-
  "contact_company":"Acme Consulting",
+
-
  "contact_phone_home":"303-555-1234",
+
-
  "contact_phone_work":"303-555-1235",
+
-
  "contact_phone_mobile":"303-555-1236",
+
-
  "contact_phone_fax":"303-555-1237",
+
-
  "contact_business_street":"123 Church Street",
+
-
  "contact_business_street2":"Suite 12",
+
-
  "contact_business_city":"Shady Acres",
+
-
  "contact_business_state":"CO",
+
-
  "contact_business_zip":"12345",
+
-
  "contact_home_street":"124 Church Street",
+
-
  "contact_home_street2":"",
+
-
  "contact_home_city":"Shady Acres",
+
-
  "contact_home_state":"CO",
+
-
  "contact_home_zip":"12345",
+
-
  "contact_date":"2010-07-16 22:34:01",
+
-
  "contact_self":"0"
+
-
}
+
-
...
+
-
]
+
-
</source>
+
-
=== Example Response - TEXT (pipe-delimited) ===
+
// Set the necessary parameters
-
<div style="overflow: auto;">
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
-
<source lang="text">
+
curl_setopt($ch, CURLOPT_USERPWD, $strUsername . ':' . $strPassword);
-
contact_id|contact_name|contact_email|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|contact_date|contact_self
+
curl_setopt($ch, CURLOPT_URL, $strBaseURI . $strResourcePath);
-
123456|Jane Smith|jane.smith@company.com|Active|Consultant|Acme Consulting|303-555-1234|303-555-1235|303-555-1236|303-555-1237|123 Church Street|Suite 12|Shady Acres|CO|12345|124 Church Street||Shady Acres|CO|12345|2010-07-16 22:34:01|0
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $strResponseFormat, 'Content-type: ' . $strRequestFormat));
-
...
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
-
</source>
+
curl_setopt($ch, CURLOPT_POST, 1);
-
</div>
+
 
-
[[Category:Resource Definitions]]
+
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>

Revision as of 16:04, 17 July 2010

<?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