Skip to content

Latest commit

 

History

History
257 lines (178 loc) · 5.26 KB

README-v1.0.0.md

File metadata and controls

257 lines (178 loc) · 5.26 KB

php-api v1.0.0

PHP Client to Access Agile Functionality

Intro

  1. Fill in the your agile API key and agile domain in the file curlwrap_v1.php

  2. Copy and paste the source of curlwrap_v1.php in your php code.

  3. You need to provide 3 parameters to the curl_wrap function. They are subject, JSON data and action.

a. subject should be one of "contact", "tags", "score", "note", "task", "deal".

b. JSON data

JSON data format should be as shown below. Email is mandatory.
 $contact_json = array(
    					"email" => "[email protected]",
    					"first_name" => "test",
    					"last_name" => "contact",
    					"tags" => "tag1, tag2"
					  );
    			  
 $contact_json = json_encode($contact_json);

c. action parameter must to set to

POST if you need to add an entity to contact like tags, or contact itself.

GET if you need to fetch an entity associated with the contact.

PUT to update contact properties, add / subtract score, or remove tags.

DELETE to delete a contact.

Usage

1. Contact

1.1 To create a contact
$contact_json = array(
	"email" => "[email protected]",
    "first_name" => "test",
    "last_name" => "contact",
    "tags" => "tag1, tag2",
    "company" => "abc corp",
    "title" => "lead",
    "phone" => "+1-541-754-3010",
    "website" => "http://www.example.com",
    "address" => "{\"city\":\"new delhi\", \"state\":\"delhi\",\"country\":\"india\"}"
    );

$contact_json = json_encode($contact_json);

curl_wrap("contact", $contact_json, "POST");
1.2 To fetch contact data
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("contact", $json, "GET");
1.3 To delete a contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("contact", $json, "DELETE");
1.4 To update a contact
$contact_json =	array(
    					"email" => "[email protected]",
    					"website" => "http://www.example.com",
    					"company" => "abc corp"
					 );
			 		
$contact_json = json_encode($contact_json);

curl_wrap("contact", $contact_json, "PUT");
  • 1.4.1 Adding custom property
$contact_json =	array(
    					"email" => "[email protected]",
    					"custom_property_name" => "custom_property_value"
    				 );
			 		
$contact_json = json_encode($contact_json);

curl_wrap("contact", $contact_json, "PUT");

2. Note

2.1 To add Note
$note_json = array(
					"email" => "[email protected]",
					"subject" => "test",
					"description" => "note added"
		 		  );
		 		
$note_json = json_encode($note_json);

curl_wrap("note", $note_json, "POST");
2.2 To fetch notes related to contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("note", $json, "GET");

3. Score

3.1 To add score to contact
$score_json = array(
    				"email" => "[email protected]",
    				"score" => "50"
		 		   );
		 		
$score_json = json_encode($score_json);

curl_wrap("score", $score_json, "PUT");
3.2 To get the score related to particular contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("score", $json, "GET");
3.3 To subtract the score of contact
$subscore_json = array("email" => "[email protected]", "score" => "-20");

$subscore_json = json_encode($subscore_json);

curl_wrap("score", $json, "PUT");

4. Task

4.1 To add task to contact
$task_json = array(	
					"email" => "[email protected]",
					"type" => "MEETING",
					"priority_type" => "HIGH",
					"subject" => "test",
					"due" => "1376047332"
				  );
				
$task_json = json_encode($task_json);
				
curl_wrap("tags", $tag_json, "POST");
4.2 To get tasks related to contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("task", $json, "GET");

5. Deal

5.1 To add deal to contact
$deal_json = array(
					"email" => "[email protected]",
					"name" => "Test Deal",
					"description" => "testing deal",
					"expected_value" => "100",
					"milestone" => "won",
					"probability" => "5",
					"close_date" => "1376047332"
				  );
	       	 
$deal_json = json_encode($deal_json);

curl_wrap("deal", $deal_json, "POST");
5.2 To get deals related to contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("deal", $json, "GET");

6. Tags

6.1 To add tags to contact
$tag_json = array(
					"email" => "[email protected]",
					"tags" => "tag1, tag2, tag3, tag4, tag5"
				 );
			
$tag_json = json_encode($tag_json);
							
curl_wrap("tags", $tag_json, "POST");
6.2 To get tags related to contact
$json = array("email" => "[email protected]");

$json = json_encode($json);

curl_wrap("tags", $json, "GET");
6.3 To remove tags related to contact
$rm_tags_json = array(
						"email" => "[email protected]",
						"tags" => "tag3, tag4"
					 );
				
$rm_tags_json = json_encode($rm_tags_json);
				
curl_wrap("tags", $rm_tags_json, "PUT");

For example implementation of all available API refer to sample.php.