#PHP API v2.0.0 PHP Client to access Agile functionality
#Intro
-
Fill in your AGILE_DOMAIN, AGILE_USER_EMAIL, AGILE_REST_API_KEY in curlwrap_v2.php.
-
Copy and paste the source / include the curlwrap_v2.php in your php code.
-
You need to provide 3 paramaters to the curl_wrap function. They are $entity, $data, $method.
-
$entity should be one of "contacts/{id}", "contacts", "opportunity/{id}", "opportunity", "notes", "contacts/{contact_id}/notes", "contacts/{contact_id}/notes/{note_id}", "tasks/{id}", "tasks", "events", "events/{id}", "milestone/pipelines", "milestone/pipelines/{id}" depending on requirement.
-
$data must be stringified JSON.
$data = array(
"properties"=>array(
array(
"name"=>"first_name",
"value"=>"phprest",
"type"=>"SYSTEM"
),
array(
"name"=>"last_name",
"value"=>"contact",
"type"=>"SYSTEM"
),
array(
"name"=>"email",
"value"=>"[email protected]",
"type"=>"SYSTEM"
)
)
);
$data = json_encode($data);
-
$method can be set to
POST to create an entity (contact, deal, task, event). GET to fetch an entity. PUT to update entity. DELETE to remove an entity.
#Usage
$contact_json = array(
"properties"=>array(
array(
"name"=>"first_name",
"value"=>"phprest",
"type"=>"SYSTEM"
),
array(
"name"=>"last_name",
"value"=>"contact",
"type"=>"SYSTEM"
),
array(
"name"=>"email",
"value"=>"[email protected]",
"type"=>"SYSTEM"
)
)
);
$contact_json = json_encode($contact_json);
curl_wrap("contacts", $contact_json, "POST");
curl_wrap("contacts/5722721933590528", null, "GET");
curl_wrap("contacts/5722721933590528", null, "DELETE");
$contact_json = array(
"id"=>5722721933590528,
"properties"=>array(
array(
"name"=>"first_name",
"value"=>"php",
"type"=>"SYSTEM"
),
array(
"name"=>"last_name",
"value"=>"contact",
"type"=>"SYSTEM"
),
array(
"name"=>"email",
"value"=>"[email protected]",
"type"=>"SYSTEM"
)
)
);
$contact_json = json_encode($contact_json);
curl_wrap("contacts", $contact_json, "PUT");
$company_json = array(
"type"=>"COMPANY",
"properties"=>array(
array(
"name"=>"name",
"value"=>"test company",
"type"=>"SYSTEM"
),
array(
"name"=>"url",
"value"=>"https://www.testcompany.org",
"type"=>"SYSTEM"
)
)
);
$company_json = json_encode($company_json);
curl_wrap("contacts", $company_json, "POST");
curl_wrap("contacts/5695414665740288", null, "GET");
curl_wrap("contacts/5695414665740288", null, "DELETE")
$company_json = array(
"id"=>5695414665740288,
"type"=>"COMPANY",
"properties"=>array(
array(
"name"=>"name",
"value"=>"test company",
"type"=>"SYSTEM"
),
array(
"name"=>"url",
"value"=>"https://www.test-company.org",
"type"=>"SYSTEM"
)
)
);
$company_json = json_encode($company_json);
curl_wrap("contacts", $company_json, "PUT");
$opportunity_json = array(
"name"=>"test deal",
"description"=>"this is a test deal",
"expected_value"=>1000,
"milestone"=>"Open",
"probability"=>50,
"close_date"=>1414317504,
"contact_ids"=>array(5722721933590528)
);
$opportunity_json = json_encode($opportunity_json);
curl_wrap("opportunity", $opportunity_json, "POST");
curl_wrap("opportunity/5739083074633728", null, "GET");
curl_wrap("opportunity/5739083074633728", null, "DELETE");
$opportunity_json = array(
"id"=>5739083074633728,
"name"=>"test",
"description"=>"this is a test deal",
"expected_value"=>1000,
"milestone"=>"Open",
"probability"=>50,
"close_date"=>1414317504,
"contact_ids"=>array(5722721933590528)
);
$opportunity_json = json_encode($opportunity_json);
curl_wrap("opportunity", $opportunity_json, "PUT");
$note_json = array(
"subject"=>"test note",
"description"=>"this is a test note",
"contact_ids"=>array(5722721933590528),
"owner_id"=>3103059
);
$note_json = json_encode($note_json);
curl_wrap("notes", $note_json, POST);
curl_wrap("contacts/5722721933590528/notes", null, "GET");
$note_json = array(
"id"=>1414322285,
"subject"=>"note",
"description"=>"this is a test note",
"contact_ids"=>array(5722721933590528),
"owner_id"=>3103059
);
$note_json = json_encode($note_json);
curl_wrap("notes", $note_json, "PUT");
$task_json = array(
"type"=>"MILESTONE",
"priority_type"=>"HIGH",
"due"=>1414671165,
"contacts"=>array(5722721933590528),
"subject"=>"this is a test task",
"status"=>"YET_TO_START",
"owner_id"=>3103059
);
$task_json = json_encode($task_json);
curl_wrap("tasks", $task_json, "POST");
curl_wrap("tasks/5752207420948480", null, "GET");
curl_wrap("tasks/5752207420948480", null, "DELETE");
$task_json = array(
"id"=>5752207420948480,
"type"=>"MILESTONE",
"priority_type"=>"LOW",
"due"=>1414671165,
"contacts"=>array(5722721933590528),
"subject"=>"this is a test task",
"status"=>"YET_TO_START",
"owner_id"=>3103059
);
$task_json = json_encode($task_json);
curl_wrap("tasks", $task_json, "PUT");
$event_json = array(
"start"=>1414155679,
"end"=>1414328479,
"title"=>"this is a test event",
"contacts"=>array(5722721933590528),
"allDay"=>true
);
$event_json = json_encode($event_json);
curl_wrap("events", $event_json, "POST");
curl_wrap("events/5703789046661120", null, "DELETE");
$event_json = array(
"id"=>5703789046661120,
"start"=>1414155679,
"end"=>1414328479,
"title"=>"this is a test event",
"contacts"=>array(5722721933590528),
"allDay"=>false
);
$event_json = json_encode($event_json);
curl_wrap("events", $event_json, "PUT");
$milestone_json = array(
"name"=>"new",
"milestones"=>"one, two, three"
);
$milestone_json = json_encode($milestone_json);
curl_wrap("milestone/pipelines", $milestone_json, "POST")
curl_wrap("milestone/pipelines", null, "GET");
$milestone_json = array(
"id"=>5659711005261824,
"name"=>"latest",
"milestones"=>"one, two, three, four"
);
$milestone_json = json_encode($milestone_json);
curl_wrap("milestone/pipelines", $milestone_json, "PUT");
curl_wrap("milestone/pipelines/5659711005261824", null, "DELETE");
- The curlwrap_v*.php is based on https://gist.github.com/apanzerj/2920899 authored by Adam Panzer.