// **************************Create Deal******************************** $opportunity_json = array("name" => "test deal", "description" => "this is a test deal", "expected_value" => 1000, "milestone" => "Open", "custom_data" => array(array("name" => "dataone", "value" => "xyz"), array("name" => "datatwo", "value" => "abc")), "probability" => 50, "close_date" => 1414317504, "contact_ids" => array("5732642569846784", "5756422495141888")); $opportunity_json_input = json_encode($opportunity_json); $deal3 = curl_wrap("opportunity", $opportunity_json_input, "POST", "application/json"); echo $deal3; // **************************Update Deal******************************** // Note : To use this method, you have to send all data related to this deal id // Note : Otherwise you can lose other data, which is not sent. Better use partial update $opportunity_json = array("id" => "5756188201320448", "name" => "test deal", "description" => "this is a test deal", "expected_value" => 2000, "milestone" => "Open", "custom_data" => array(array("name" => "dataone", "value" => "xyz"), array("name" => "datatwo", "value" => "abc")), "probability" => 80, "close_date" => 1414317504, "contact_ids" => array("5732642569846784", "5756422495141888")); $opportunity_json_input = json_encode($opportunity_json); $deal4 = curl_wrap("opportunity", $opportunity_json_input, "PUT", "application/json"); echo $deal4; // **************************Update Deal (Partial update)******************************** // Note : No need to send all the data of a deal only the properties want to update // Pipeline id is the track id : more info - https://github.com/agilecrm/rest-api#devapimilestonepipelines // Each track has milestones (New,Open,Prospect etc.) // Each track has id called track id or pipeline id. // If pipeline id is not given then default track will be updated with new milestone. $opportunity_json = array("id" => "5756188201320448", "name" => "test deal", "description" => "this is a test deal", "expected_value" => 3000, "milestone" => "Open", "pipeline_id" => "5756422495141836", "custom_data" => array(array("name" => "dataone", "value" => "xyz")), "contact_ids" => array("5732642569846784", "5756422495141888")); $opportunity_json_input = json_encode($opportunity_json); $deal5 = curl_wrap("opportunity/partial-update", $opportunity_json_input, "PUT", "application/json"); echo $deal5; // **************************delete a deal By deal id.******************** $deal6 = curl_wrap("opportunity/5193632629915648", null, "DELETE", "application/json"); echo 'deal delete successfully'; echo '<br/><br/><br/><br/>'; // **************************Get all the Tracks******************** // Note: Will return list. iterate to get specific track id / pipeline id and corresponding milestones. $tracks = curl_wrap("milestone/pipelines", null, "GET", "application/json"); echo $tracks; echo '<br/><br/><br/><br/>';
curl_wrap("score", $json, "GET"); # To add task $task_json = array("type" => "MEETING", "priority_type" => "HIGH", "subject" => "test", "email" => "*****@*****.**"); $task_json = json_encode($task_json); curl_wrap("task", $task_json, "POST"); # To get tasks related to a contact $json = array("email" => "*****@*****.**"); $json = json_encode($json); curl_wrap("task", $json, "GET"); # To add a deal to contact $deal_json = array("name" => "Test Deal", "description" => "testing deal", "expected_value" => "100", "milestone" => "won", "probability" => "5", "close_date" => "1376047332", "email" => "*****@*****.**"); # close date in epoch time $deal_json = json_encode($deal_json); curl_wrap("deal", $deal_json, "POST"); # To get deals associated with contact $json = array("email" => "*****@*****.**"); $json = json_encode($json); curl_wrap("deal", $json, "GET"); # To add tags $tag_json = array("email" => "*****@*****.**", "tags" => "tag1, tag2, tag3, tag4, tag5"); $tag_json = json_encode($tag_json); curl_wrap("tags", $tag_json, "POST"); # To delete tags $rm_tags_json = array("tags" => "tag3, tag4", "email" => "*****@*****.**"); $rm_tags_json = json_encode($rm_tags_json); curl_wrap("tags", $rm_tags_json, "PUT"); # To get tags assigned to a contact $json = array("email" => "*****@*****.**"); $json = json_encode($json); curl_wrap("tags", $json, "GET");
<!DOCTYPE html> <!-- Agile CRM \ index file for basic test Test the connection's with agile crm api and return a contact. --> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <?php include "CurlLib/curlwrap_v2.php"; echo "<h2>Reference taken from : https://github.com/agilecrm/php-api</h2>"; echo '<br/>'; $contact = curl_wrap("contacts/search/email/haka@gmail.com", null, "GET", NULL); echo $contact; ?> </body> </html>
// **************************Edit star value contact id ******************************** $contact_json_star = array("id" => "5722721933590528", "star_value" => "5"); $contact_json_star_input = json_encode($contact_json_star); $contact7 = curl_wrap("contacts/edit/add-star", $contact_json_star_input, "PUT", "application/json"); echo $contact7; // **************************Edit score by contact id **************** $contact_json_lead_score = array("id" => 5722721933590528, "lead_score" => "5"); $contact_json_lead_score_input = json_encode($contact_json_lead_score); $contact8 = curl_wrap("contacts/edit/lead-score", $contact_json_lead_score_input, "PUT", "application/json"); echo $contact8; // **************************Add tags to a contact by email ******************************** $form_fields1 = array('email' => urlencode("*****@*****.**"), 'tags' => urlencode('["testing"]')); $fields_string1 = ''; foreach ($form_fields1 as $key => $value) { $fields_string1 .= $key . '=' . $value . '&'; } $tags1 = curl_wrap("contacts/email/tags/add", rtrim($fields_string1, '&'), "POST", "application/x-www-form-urlencoded"); echo $tags1; // **************************Delete tags to a contact by email ******************************** $form_fields2 = array('email' => urlencode("*****@*****.**"), 'tags' => urlencode('["testing"]')); $fields_string2 = ''; foreach ($form_fields2 as $key => $value) { $fields_string2 .= $key . '=' . $value . '&'; } $tags2 = curl_wrap("contacts/email/tags/delete", rtrim($fields_string2, '&'), "POST", "application/x-www-form-urlencoded"); echo $tags2; // **************************Update tags value by contact id **************** $contact_json_tags = array("id" => "5643140853661696", "tags" => array("Player", "Winner")); $contact_json_tags_input = json_encode($contact_json_tags); $contac9 = curl_wrap("contacts/edit/tags", $contact_json_tags_input, "PUT", "application/json"); echo '$contac9';
<?php /** * Agile CRM \ note_sample_test * * Test all basic methods with contact. * * @author Agile CRM developers <Ghanshyam> */ include "../CurlLib/curlwrap_v2.php"; echo "<h2>Reference taken from : https://github.com/agilecrm/php-api</h2>"; echo '<br/>'; $note_json = array("subject" => "test note", "description" => "this is a test note", "contact_ids" => array("5641841626054656", "5756422495141888")); $note_json_input = json_encode($note_json); $note = curl_wrap("notes", $note_json_input, "POST", "application/json"); echo $note;
<?php /** * Agile CRM \ task_sample_test * * Test all basic methods with contact. * * @author Agile CRM developers <Ghanshyam> */ include "../CurlLib/curlwrap_v2.php"; echo "<h2>Reference taken from : https://github.com/agilecrm/php-api</h2>"; echo '<br/>'; $task_json = array("type" => "MILESTONE", "priority_type" => "HIGH", "contacts" => array("5641841626054656", "5756422495141888"), "subject" => "this is a test task", "status" => "YET_TO_START"); $task_json_input = json_encode($task_json); $task = curl_wrap("tasks", $task_json_input, "POST", "application/json"); echo $task;
/* ------------------------------------get contact by contact_id END----------------------------------------- */ /* ------------------------------------delete contact by contact_id ----------------------------------------- */ echo "<li>get contact with email id and find also conatct id</li><br>"; echo "<br>"; $result = curl_wrap("contacts/5632908932939776", null, "DELETE"); echo "<li>deleted response received is ...</li><br>"; echo "<li>" . $result . "</li>"; echo "<br><hr><br>"; /* ------------------------------------delete contact by contact_id END----------------------------------------- */ /*=================================================== create deal=======================================*/ $opportunity_json = array("name" => "test deal1", "description" => "this is a test deal", "expected_value" => 1000, "milestone" => "New", "custom_data" => array(array("name" => "dataone", "value" => "xyz"), array("name" => "datatwo", "value" => "abc")), "probability" => 50, "close_date" => 1438948949, "contact_ids" => array("5706163895140352")); $opportunity_json = json_encode($opportunity_json); echo "<li>create deal with below data</li><br>"; echo "<li>" . $opportunity_json . "</li><br>"; $result = curl_wrap("opportunity", $opportunity_json, "POST"); echo "<li>created deal data is ...</li><br>"; echo "<li>" . $result . "</li>"; echo "<br><hr><br>"; /*===================================================== create deal end================================================*/ /*===================================================== update deal================================================*/ $opportunity_json = array("id" => "5675214360805376", "name" => "test deal1 updated", "description" => "this is a test deal", "expected_value" => 1000, "milestone" => "Won", "custom_data" => array(array("name" => "dataone", "value" => "xyz updated"), array("name" => "datatwo", "value" => "abc updated")), "probability" => 50, "close_date" => 1438949981, "contact_ids" => array("5706163895140352")); $opportunity_json = json_encode($opportunity_json); echo "<li>update deal with below data</li><br>"; echo "<li>" . $opportunity_json . "</li><br>"; $result = curl_wrap("opportunity", $opportunity_json, "POST"); echo "<li>updated deal data is ...</li><br>"; echo "<li>" . $result . "</li>"; echo "<br><hr><br>"; /*================================================= update deal end================================================*/ echo "</ul>"; echo "</body></html>";