PHP Client to Access Agile Functionality
-
Fill in the your agile API key and agile domain in the file curlwrap_v1.php
-
Copy and paste the source of curlwrap_v1.php in your php code.
-
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.
$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");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("contact", $json, "GET");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("contact", $json, "DELETE");
$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");
$note_json = array(
"email" => "[email protected]",
"subject" => "test",
"description" => "note added"
);
$note_json = json_encode($note_json);
curl_wrap("note", $note_json, "POST");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("note", $json, "GET");
$score_json = array(
"email" => "[email protected]",
"score" => "50"
);
$score_json = json_encode($score_json);
curl_wrap("score", $score_json, "PUT");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("score", $json, "GET");
$subscore_json = array("email" => "[email protected]", "score" => "-20");
$subscore_json = json_encode($subscore_json);
curl_wrap("score", $json, "PUT");
$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");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("task", $json, "GET");
$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");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("deal", $json, "GET");
$tag_json = array(
"email" => "[email protected]",
"tags" => "tag1, tag2, tag3, tag4, tag5"
);
$tag_json = json_encode($tag_json);
curl_wrap("tags", $tag_json, "POST");
$json = array("email" => "[email protected]");
$json = json_encode($json);
curl_wrap("tags", $json, "GET");
$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.