Code Examples

From API Documentation

(Difference between revisions)
Jump to: navigation, search
m (Reverted edits by AngelSlayerL0AZ (Talk) to last revision by WikiSysop)
Line 1: Line 1:
-
There are very a few possibilities which any human being getting can consider advantage of, when searching for to safeguard their eye balls as well as take advantage of the benefits found out with sunglasses.[http://www.comprarenlineaemu.com/ chaussures de sport] , even although many reseller environments function generic eyeglasses that any human being getting can purchase at a reasonably minimal price, all these eyeglasses are typically minimal in best quality as well as don't provide you the top amount of benefits.[http://www.kopengoedkopeemu.com/ canvas schoenen] , instead of spending within of a generic or arbitrary sunglasses opportunity, pursue the specific design chance which may possibly be found out with purchase into Prada glasses.[http://www.thomassaboonsale.com/ thomas sabo jewellery] ,
+
Below are examples of how to access the API using PHP. These examples demonstrate a variety of available methods and content formats. While we do not cover every possible use of the API here, these examples are meant to be indicative of all API calls.
-
Most individuals are properly mindful belonging to the considerable possibilities that are designed once they invest into eyesight protection, like Prada glasses.[http://www.hotiffanyjewelry.com/ tiffany] , What many individuals understand is at any time you make the intelligent purchase into this specific brand, you can even consider an awesome advantage belonging to the extraordinary opportunity of owning your contacts customized to fulfill any prescription demands you may just have.[http://www.buyuggsbootonsale.com/ leather uggs] , It is extremely useful this sort of that any human being getting consists of a specific opportunity of not just guarding their eyes, but acquiring the greatest level of visual clarity.
+
All examples use the cURL library for handling the HTTP request. There are other methods available in PHP (and other languages, of course), and any means that allows you to send and receive the properly formatted requests and responses is perfectly acceptable.
-
When looking in to the chance of Prada glasses, a human being getting can most typically choose by means of the conventional types offered by Prada or research for the odds of Prada Sport. When first looking in to the odds of buying Prada, an enormous percentage of individuals are at first drawn to the traditional types that this institution over a normal schedule supports. Essayslab.com has been working in the essay writing industry for a while. Recently I have chosen them to [http://essayslab.com write my paper]. And you know what? They coped with this task very well, although it was not the easiest one. Usually I write my paper on my own, but that time I was in need of professional assistance. So this post is kind of �thank you�. Prada is properly recognised for getting amid probably the most crucial influences using the pattern world, even if its a accomplish result of the clothing, their personal accessories, or their extraordinary glasses.
+
== Example 1: read the ''agents'' collection resource ==
 +
<source lang="php">
 +
<?php
 +
// Set some universal configuration variables. These will be
 +
// the same for all your API requests for a particular account.
 +
$strUsername = 'YOUR_API_USERNAME';
 +
$strPassword = 'YOUR_API_PASSWORD';
 +
$strBaseURI = 'http://api.rezora.com/v1/';
-
When you ike to think about an awesome advantage belonging to the brand new evolution of Prada creations, just one of your top options may possibly be found out with Prada Sport. This new collection of eyeglasses has embraced the believed of the additional youthful and energetic culture, as additional individuals consider advantage belonging to the outside surroundings as well as a extremely athletic lifestyle. When buying these kinds of Prada glasses, you can possess the ability to advantage from sleek styles and comparable lines, which'll support to improve your odds to take satisfaction in the outside environment, even although getting benefit of the traditional brand.
+
// Set some configuration variables specific to the task at hand.
 +
// In this example, we'll be reading data from the agents collection
 +
// resource. We'll retrieve the data in CSV format.
 +
$strResourcePath = 'agents';
 +
$strRequestFormat = 'text/plain';
 +
$strResponseFormat = 'text/csv';
-
If the extraordinary odds that are designed with Prada eyeglasses appeal for the customer interests, then make the intelligent purchase choice by pursuing options by means of the on-line investment, to purchase these glasses. even although there are very a few firms that could openly promote which they hold the Prada brand, all these ads also can be found with raises in price, getting a accomplish result belonging to the considerable fees that could be found out using the reseller environment. at any time you consider advantage belonging to the considerable level of competing found out using the on-line environment, you can possess the ability to advantage from astonishingly decreased fees for every solitary brand, which include Prada.
+
// 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_RETURNTRANSFER, true);
 +
 
 +
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>
 +
</source>
 +
 
 +
== Example 2: read the ''agents/ID'' resource ==
 +
<source lang="php">
 +
<?php
 +
// Set some universal configuration variables. These will be
 +
// the same for all your API requests for a particular account.
 +
$strUsername = 'YOUR_API_USERNAME';
 +
$strPassword = 'YOUR_API_PASSWORD';
 +
$strBaseURI = 'http://api.rezora.com/v1/';
 +
 
 +
// Set some configuration variables specific to the task at hand.
 +
// In this example, we'll be reading data from the resource for
 +
// an agent with the ID 1234. We'll retrieve the data in XML format.
 +
// Notice that the presence of the .xml extension will override the
 +
// Accept header value ($strResponseFormat). Alternatively, you
 +
// could leave off the extension and set the Accept header value
 +
// ($strResponseFormat) to application/xml.
 +
$strResourcePath = 'agents/1234.xml';
 +
$strRequestFormat = 'text/plain';
 +
$strResponseFormat = 'text/csv';
 +
 
 +
// 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_RETURNTRANSFER, true);
 +
 
 +
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>
 +
</source>
 +
 
 +
== Example 3: add a new contact to the ''contacts'' collection resource ==
 +
<source lang="php">
 +
<?php
 +
// Set some universal configuration variables. These will be
 +
// the same for all your API requests for a particular account.
 +
$strUsername = 'YOUR_API_USERNAME';
 +
$strPassword = 'YOUR_API_PASSWORD';
 +
$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 send data in JSON format,
 +
// and retrieve data in XML format.
 +
$strResourcePath = 'contacts';
 +
$strRequestFormat = 'application/json';
 +
$strResponseFormat = 'application/xml';
 +
$strData = '{
 +
"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"
 +
}
 +
}
 +
';
 +
 
 +
// Open a cURL resource
 +
$ch = curl_init();
 +
 
 +
// Set the necessary parameters
 +
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
 +
curl_setopt($ch, CURLOPT_USERPWD, $strUsername . EssaysExperts.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://www.essaysexperts.com essays online]. EssaysExperts.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://www.essaysexperts.com/essays-online.html essays online]. If you still have no idea where to buy your writing tasks, this company is the best option for you. If you still have no idea where to buy your writing tasks, this company is the best option for you. ':' . $strPassword);
 +
curl_setopt($ch, CURLOPT_URL, $strBaseURI . $strResourcePath);
 +
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $strResponseFormat, 'Content-type: ' . $strRequestFormat));
 +
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 +
 
 +
// Make this a POST request
 +
curl_setopt($ch, CURLOPT_POST, true);
 +
curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
 +
 
 +
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>
 +
</source>
 +
 
 +
== Example 4: update an individual contact from the ''contacts/ID'' resource ==
 +
<source lang="php">
 +
<?php
 +
// Set some universal configuration variables. These will be
 +
// the same for all your API requests for a particular account.
 +
$strUsername = 'YOUR_API_USERNAME';
 +
$strPassword = 'YOUR_API_PASSWORD';
 +
$strBaseURI = 'http://api.rezora.com/v1/';
 +
 
 +
// Set some configuration variables specific to the task at hand.
 +
// In this example, we'll be updating data for an existing contact resource.
 +
// We'll send data in XML format, and retrieve data in CSV format.
 +
$strResourcePath = 'contacts/123456';
 +
$strRequestFormat = 'application/xml';
 +
$strResponseFormat = 'text/csv';
 +
$strData = '<?xml version="1.0" encoding="UTF-8"?>
 +
<data>
 +
<contact_name>Jane Smith-Johnson</contact_name>
 +
<contact_email>jane.smith.johnson@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>
 +
';
 +
 
 +
// 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_RETURNTRANSFER, true);
 +
 
 +
// PUT is originally intended for uploading files,
 +
// so we have to make our data look like a file.
 +
// Open a file resource using the php://memory stream
 +
$fh = fopen('php://memory', 'rw');
 +
 
 +
// Write the data to the file
 +
fwrite($fh, $strData);
 +
 
 +
// Move back to the beginning of the file
 +
rewind($fh);
 +
 
 +
// Make this a PUT request
 +
curl_setopt($ch, CURLOPT_PUT, true);
 +
curl_setopt($ch, CURLOPT_INFILE, $fh);
 +
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($strData));
 +
 
 +
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the file resource
 +
fclose($fh);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>
 +
</source>
 +
 
 +
== Example 5: delete all contacts from the ''contacts'' collection resource ==
 +
<source lang="php">
 +
<?php
 +
// Set some universal configuration variables. These will be
 +
// the same for all your API requests for a particular account.
 +
$strUsername = 'YOUR_API_USERNAME';
 +
$strPassword = 'YOUR_API_PASSWORD';
 +
$strBaseURI = 'http://api.rezora.com/v1/';
 +
 
 +
// Set some configuration variables specific to the task at hand.
 +
// In this example, we'll be deleting data from the contacts collection
 +
// resource. We'll retrieve the data in JSON format.
 +
$strResourcePath = 'contacts';
 +
$strRequestFormat = 'text/plain';
 +
$strResponseFormat = 'application/json';
 +
 
 +
// 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_RETURNTRANSFER, true);
 +
 
 +
// Make this a DELETE request
 +
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
 +
 
 +
// Make the request and output the response.
 +
echo curl_exec($ch);
 +
 
 +
// Close the cURL resource
 +
curl_close($ch);
 +
?>
 +
</source>

Revision as of 16:46, 1 March 2012

Below are examples of how to access the API using PHP. These examples demonstrate a variety of available methods and content formats. While we do not cover every possible use of the API here, these examples are meant to be indicative of all API calls.

All examples use the cURL library for handling the HTTP request. There are other methods available in PHP (and other languages, of course), and any means that allows you to send and receive the properly formatted requests and responses is perfectly acceptable.

Contents

Example 1: read the agents collection resource

<?php
// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$strBaseURI = 'http://api.rezora.com/v1/';
 
// Set some configuration variables specific to the task at hand.
// In this example, we'll be reading data from the agents collection
// resource. We'll retrieve the data in CSV format.
$strResourcePath = 'agents';
$strRequestFormat = 'text/plain';
$strResponseFormat = 'text/csv';
 
// 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_RETURNTRANSFER, true);
 
// Make the request and output the response.
echo curl_exec($ch);
 
// Close the cURL resource
curl_close($ch);
?>

Example 2: read the agents/ID resource

<?php
// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$strBaseURI = 'http://api.rezora.com/v1/';
 
// Set some configuration variables specific to the task at hand.
// In this example, we'll be reading data from the resource for
// an agent with the ID 1234. We'll retrieve the data in XML format.
// Notice that the presence of the .xml extension will override the
// Accept header value ($strResponseFormat). Alternatively, you
// could leave off the extension and set the Accept header value
// ($strResponseFormat) to application/xml.
$strResourcePath = 'agents/1234.xml';
$strRequestFormat = 'text/plain';
$strResponseFormat = 'text/csv';
 
// 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_RETURNTRANSFER, true);
 
// Make the request and output the response.
echo curl_exec($ch);
 
// Close the cURL resource
curl_close($ch);
?>

Example 3: add a new contact to the contacts collection resource

<?php
// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$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 send data in JSON format,
// and retrieve data in XML format.
$strResourcePath = 'contacts';
$strRequestFormat = 'application/json';
$strResponseFormat = 'application/xml';
$strData = '{
 "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"
 }
}
';
 
// Open a cURL resource
$ch = curl_init();
 
// Set the necessary parameters
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_USERPWD, $strUsername . EssaysExperts.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://www.essaysexperts.com essays online]. EssaysExperts.Com is the company which first and main priority was, is and will be customers� satisfaction with the [http://www.essaysexperts.com/essays-online.html essays online]. If you still have no idea where to buy your writing tasks, this company is the best option for you. If you still have no idea where to buy your writing tasks, this company is the best option for you. ':' . $strPassword);
curl_setopt($ch, CURLOPT_URL, $strBaseURI . $strResourcePath);
curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $strResponseFormat, 'Content-type: ' . $strRequestFormat));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
// Make this a POST request
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $strData);
 
// Make the request and output the response.
echo curl_exec($ch);
 
// Close the cURL resource
curl_close($ch);
?>

Example 4: update an individual contact from the contacts/ID resource

<?php
// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$strBaseURI = 'http://api.rezora.com/v1/';
 
// Set some configuration variables specific to the task at hand.
// In this example, we'll be updating data for an existing contact resource.
// We'll send data in XML format, and retrieve data in CSV format.
$strResourcePath = 'contacts/123456';
$strRequestFormat = 'application/xml';
$strResponseFormat = 'text/csv';
$strData = '<?xml version="1.0" encoding="UTF-8"?>
<data>
 <contact_name>Jane Smith-Johnson</contact_name>
 <contact_email>jane.smith.johnson@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>
';
 
// 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_RETURNTRANSFER, true);
 
// PUT is originally intended for uploading files,
// so we have to make our data look like a file.
// Open a file resource using the php://memory stream
$fh = fopen('php://memory', 'rw');
 
// Write the data to the file
fwrite($fh, $strData);
 
// Move back to the beginning of the file
rewind($fh);
 
// Make this a PUT request
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $fh);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($strData));
 
// Make the request and output the response.
echo curl_exec($ch);
 
// Close the file resource
fclose($fh);
 
// Close the cURL resource
curl_close($ch);
?>

Example 5: delete all contacts from the contacts collection resource

<?php
// Set some universal configuration variables. These will be
// the same for all your API requests for a particular account.
$strUsername = 'YOUR_API_USERNAME';
$strPassword = 'YOUR_API_PASSWORD';
$strBaseURI = 'http://api.rezora.com/v1/';
 
// Set some configuration variables specific to the task at hand.
// In this example, we'll be deleting data from the contacts collection
// resource. We'll retrieve the data in JSON format.
$strResourcePath = 'contacts';
$strRequestFormat = 'text/plain';
$strResponseFormat = 'application/json';
 
// 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_RETURNTRANSFER, true);
 
// Make this a DELETE request
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
 
// Make the request and output the response.
echo curl_exec($ch);
 
// Close the cURL resource
curl_close($ch);
?>
Personal tools