Skip to content

Commit 5d01637

Browse files
committed
New Version with few changes
PHP version 3.0.0 with few new API and modification in Curl wrap call.
1 parent ffd77fe commit 5d01637

10 files changed

+339
-809
lines changed

curlwrap_v2.php renamed to CurlLib/curlwrap_v2.php

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,64 @@
11
<?php
2-
define("AGILE_DOMAIN", "your_agile_domain");
3-
define("AGILE_USER_EMAIL", "your_agile_user_email");
4-
define("AGILE_REST_API_KEY", "your_agile_api_key");
52

6-
function curl_wrap($entity, $data, $method)
7-
{
8-
$agile_url = "https://" . AGILE_DOMAIN . ".agilecrm.com/dev/api/" . $entity;
9-
$agile_php_url = "https://" . AGILE_DOMAIN . ".agilecrm.com/core/php/api/" . $entity . "?id=" . AGILE_REST_API_KEY;
3+
/**
4+
* Agile CRM \ Curl Wrap
5+
*
6+
* The Curl Wrap is the entry point to all services and actions.
7+
*
8+
* @author Agile CRM developers <Ghanshyam>
9+
*/
10+
11+
12+
# Enter your domain name , agile email and agile api key
13+
define("AGILE_DOMAIN", "ghanshyam"); # Example : define("domain","jim");
14+
define("AGILE_USER_EMAIL", "[email protected]");
15+
define("AGILE_REST_API_KEY", "123456"); // Example : http://snag.gy/AEq23.jpg
16+
17+
function curl_wrap($entity, $data, $method, $content_type) {
18+
if ($content_type == NULL) {
19+
$content_type = "application/json";
20+
}
21+
22+
$agile_url = "https://" . AGILE_DOMAIN . ".agilecrm.com/dev/api/" . $entity;
1023

1124
$ch = curl_init();
1225
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
1326
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
1427
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
15-
1628
switch ($method) {
1729
case "POST":
18-
$url = ($entity == "tags" ? $agile_php_url : $agile_url);
30+
$url = $agile_url;
1931
curl_setopt($ch, CURLOPT_URL, $url);
2032
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
2133
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
2234
break;
2335
case "GET":
24-
$url = ($entity == "tags" ? $agile_php_url . '&email=' . $data->{'email'} : $agile_url);
36+
$url = $agile_url;
2537
curl_setopt($ch, CURLOPT_URL, $url);
2638
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
2739
break;
2840
case "PUT":
29-
$url = ($entity == "tags" ? $agile_php_url : $agile_url);
41+
$url = $agile_url;
3042
curl_setopt($ch, CURLOPT_URL, $url);
3143
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
3244
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
3345
break;
3446
case "DELETE":
35-
$url = ($entity == "tags" ? $agile_php_url : $agile_url);
47+
$url = $agile_url;
3648
curl_setopt($ch, CURLOPT_URL, $url);
3749
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
3850
break;
3951
default:
4052
break;
4153
}
42-
4354
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
44-
'Content-type : application/json; charset : UTF-8;',
45-
'Accept : application/json'
55+
"Content-type : $content_type;", 'Accept : application/json'
4656
));
4757
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
4858
curl_setopt($ch, CURLOPT_USERPWD, AGILE_USER_EMAIL . ':' . AGILE_REST_API_KEY);
4959
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
50-
60+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
5161
$output = curl_exec($ch);
5262
curl_close($ch);
5363
return $output;
5464
}
55-
?>

0 commit comments

Comments
 (0)