Resource Definitions:Contacts

From API Documentation

(Difference between revisions)
Jump to: navigation, search
 
(49 intermediate revisions not shown)
Line 1: Line 1:
-
<?php
+
The ''contacts'' resource is a collection of all contacts associated with your agent account.
-
// 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.
+
Each agent account has one special contact, known as the "self contact." This contact has a contact_self value of 1, while all other contacts have a contact_self value of 0. The self contact cannot be deleted. The delete all functionality deletes all contacts with a contact_self value of 0, but leaves the self contact intact.
-
// 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' => ''
+
-
);
+
 +
'''''Example URI:''''' <nowiki>http://api.rezora.com/v1/contacts</nowiki>
-
// Create an instance of the RestMakeRequest.
+
Available methods are:
-
$objRequest = new RestMakeRequest($strBaseURI . $strResourcePath, $strMethod, $arrData);
+
-
// Open a cURL resource
+
== GET ==
-
$ch = curl_init();
+
Returns a list of contacts. Each contact record includes the following fields:
-
// Set the necessary parameters
+
* contact_id
-
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
+
* contact_name
-
curl_setopt($ch, CURLOPT_USERPWD, $strUsername . ':' . $strPassword);
+
* contact_email
-
curl_setopt($ch, CURLOPT_URL, $strBaseURI . $strResourcePath);
+
* contact_type - ''possible values: Hot, Active, Inactive, empty string (indicates no type)''
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $strResponseFormat, 'Content-type: ' . $strRequestFormat));
+
* contact_title
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
+
* contact_company
-
curl_setopt($ch, CURLOPT_POST, 1);
+
* 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 - ''possible values: 0, 1 (cannot delete)''
 +
* contact_unsubscribe - ''possible values: 0 (subscribed), 1 (unsubscribed)''
-
// Make the request and output the response.
+
=== Example Responses ===
-
echo curl_exec($ch);
+
-
// Close the cURL resource
+
==== XML Response ====
-
curl_close($ch);
+
<source lang="xml">
-
?>
+
<?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_unsubscribe>0</contact_unsubscribe>
 +
</contact>
 +
...
 +
</contacts>
 +
</source>
 +
 
 +
==== JSON Response ====
 +
<source lang="javascript">
 +
[
 +
{
 +
  "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",
 +
  "contact_unsubscribe":"0"
 +
}
 +
...
 +
]
 +
</source>
 +
 
 +
==== CSV Response ====
 +
<div style="overflow: auto;">
 +
<source lang="text">
 +
"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"
 +
"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"|"0"
 +
...
 +
</source>
 +
</div>
 +
 
 +
== POST ==
 +
Adds a new contact, and returns the new contact ID. You may include the following fields (required fields marked with a red asterisk ('''<span style="color: #f00;">*</span>''')):
 +
 
 +
* contact_name
 +
* contact_email '''<span style="color: #f00;">*</span>''' - ''must be a valid email address, must be unique''
 +
* contact_type - ''accepted values: Hot, Active, Inactive, empty string (indicates no 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
 +
 
 +
=== Example Request Data ===
 +
 
 +
==== XML Request ====
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<data>
 +
<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>
 +
</data>
 +
</source>
 +
 
 +
==== JSON Request ====
 +
<source lang="javascript">
 +
{
 +
"data":{
 +
  "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"
 +
}
 +
}
 +
</source>
 +
 
 +
==== TEXT Request ====
 +
<div style="overflow: auto;">
 +
<source lang="text">
 +
contact_name=Jane+Smith&contact_email=jane.smith%40company.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
 +
</source>
 +
</div>
 +
 
 +
=== Example Response Data ===
 +
 
 +
==== XML Response ====
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<contacts version="1.0">
 +
<contact>
 +
  <contact_id>123456</contact_id>
 +
</contact>
 +
</contacts>
 +
</source>
 +
 
 +
==== JSON Response ====
 +
<source lang="javascript">
 +
[
 +
{
 +
  "contact_id":"123456"
 +
}
 +
]
 +
</source>
 +
 
 +
==== CSV Response ====
 +
<div style="overflow: auto;">
 +
<source lang="text">
 +
"contact_id"
 +
"123456"
 +
</source>
 +
</div>
 +
 
 +
== DELETE ==
 +
Permanently removes ALL contacts (except for the self contact), and returns a success code.
 +
 
 +
=== Example Response Data ===
 +
 
 +
==== XML Response ====
 +
<source lang="xml">
 +
<?xml version="1.0" encoding="UTF-8"?>
 +
<contacts version="1.0">
 +
<contact>
 +
  <status>200</status>
 +
</contact>
 +
</contacts>
 +
</source>
 +
 
 +
==== JSON Response ====
 +
<source lang="javascript">
 +
[
 +
{
 +
  "status":"200"
 +
}
 +
]
 +
</source>
 +
 
 +
==== CSV Response ====
 +
<div style="overflow: auto;">
 +
<source lang="text">
 +
"status"
 +
"200"
 +
</source>
 +
</div>
 +
[[Category:Resource Definitions]]
 +
[[Category:Agent Resources]]

Latest revision as of 21:48, 3 February 2012

The contacts resource is a collection of all contacts associated with your agent account.

Each agent account has one special contact, known as the "self contact." This contact has a contact_self value of 1, while all other contacts have a contact_self value of 0. The self contact cannot be deleted. The delete all functionality deletes all contacts with a contact_self value of 0, but leaves the self contact intact.

Example URI: http://api.rezora.com/v1/contacts

Available methods are:

Contents

GET

Returns a list of contacts. Each contact record includes the following fields:

  • contact_id
  • contact_name
  • contact_email
  • contact_type - possible values: Hot, Active, Inactive, empty string (indicates no 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 - possible values: 0, 1 (cannot delete)
  • contact_unsubscribe - possible values: 0 (subscribed), 1 (unsubscribed)

Example Responses

XML Response

<?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_unsubscribe>0</contact_unsubscribe>
 </contact>
 ...
</contacts>

JSON Response

[
 {
  "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",
  "contact_unsubscribe":"0"
 }
 ...
]

CSV Response

"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"
"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"|"0"
...

POST

Adds a new contact, and returns the new contact ID. You may include the following fields (required fields marked with a red asterisk (*)):

  • contact_name
  • contact_email * - must be a valid email address, must be unique
  • contact_type - accepted values: Hot, Active, Inactive, empty string (indicates no 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

Example Request Data

XML Request

<?xml version="1.0" encoding="UTF-8"?>
<data>
 <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>
</data>

JSON Request

{
 "data":{
  "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"
 }
}

TEXT Request

contact_name=Jane+Smith&contact_email=jane.smith%40company.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

Example Response Data

XML Response

<?xml version="1.0" encoding="UTF-8"?>
<contacts version="1.0">
 <contact>
  <contact_id>123456</contact_id>
 </contact>
</contacts>

JSON Response

[
 {
  "contact_id":"123456"
 }
]

CSV Response

"contact_id"
"123456"

DELETE

Permanently removes ALL contacts (except for the self contact), and returns a success code.

Example Response Data

XML Response

<?xml version="1.0" encoding="UTF-8"?>
<contacts version="1.0">
 <contact>
  <status>200</status>
 </contact>
</contacts>

JSON Response

[
 {
  "status":"200"
 }
]

CSV Response

"status"
"200"
Personal tools