Skip to content

Commit 330bcca

Browse files
committed
update
1 parent 2446180 commit 330bcca

File tree

3 files changed

+167
-117
lines changed

3 files changed

+167
-117
lines changed

README.md

Lines changed: 116 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PHP Client to Access Agile Functionality
99

1010
2. Copy and paste the source of curlwrap.php in your php code.
1111

12-
3. You need to provide 3 parameters to the curlWrap function. They are **subject**, **JSON data** and **action**.
12+
3. You need to provide 3 parameters to the curl_wrap function. They are **subject**, **JSON data** and **action**.
1313

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

@@ -18,12 +18,14 @@ PHP Client to Access Agile Functionality
1818
JSON data format should be as shown below. Email is mandatory.
1919

2020
```php
21-
$contact_json = '{
22-
"email" : "[email protected]",
23-
"first_name" : "test",
24-
"last_name" : "contact",
25-
"tags" : "tag1, tag2"
26-
}';
21+
$contact_json = array(
22+
"email" => "[email protected]",
23+
"first_name" => "test",
24+
"last_name" => "contact",
25+
"tags" => "tag1, tag2"
26+
);
27+
28+
$contact_json = json_encode($contact_json);
2729
```
2830

2931
c. **action parameter** must to set to
@@ -43,169 +45,201 @@ PHP Client to Access Agile Functionality
4345
###### 1.1 To create a contact
4446

4547
```php
46-
$contact_json =
48+
$contact_json = array(
4749

48-
'{
49-
"email" : "[email protected]",
50-
"first_name" : "test",
51-
"last_name" : "contact",
52-
"tags" : "tag1, tag2",
53-
"company": "abc corp",
54-
"title": "lead",
55-
"phone": "+1-541-754-3010",
56-
"website": "http://www.example.com",
57-
"address": "{\"city\":\"new delhi\", \"state\":\"delhi\",\"country\":\"india\"}"
58-
}';
5950

60-
curlWrap("contact", $contact_json, "POST");
51+
"email" => "[email protected]",
52+
"first_name" => "test",
53+
"last_name" => "contact",
54+
"tags" => "tag1, tag2",
55+
"company" => "abc corp",
56+
"title" => "lead",
57+
"phone" => "+1-541-754-3010",
58+
"website" => "http://www.example.com",
59+
"address" => "{\"city\":\"new delhi\", \"state\":\"delhi\",\"country\":\"india\"}"
60+
);
61+
62+
$contact_json = json_encode($contact_json);
63+
64+
curl_wrap("contact", $contact_json, "POST");
6165
```
6266
###### 1.2 To fetch contact data
6367

6468
```php
65-
$json = '{"email" : "[email protected]"}';
69+
$json = array("email" => "[email protected]");
6670

67-
curlWrap("contact", $json, "GET");
71+
$json = json_encode($json);
72+
73+
curl_wrap("contact", $json, "GET");
6874
```
6975
###### 1.3 To delete a contact
7076

7177
```php
72-
$json = '{"email" : "[email protected]"}';
78+
$json = array("email" => "[email protected]");
79+
80+
$json = json_encode($json);
7381

74-
curlWrap("contact", $json, "DELETE");
82+
curl_wrap("contact", $json, "DELETE");
7583
```
7684
###### 1.4 To update a contact
7785

7886
```php
79-
$contact_json = '{
80-
"email" : "[email protected]",
81-
"website" : "http://www.example.com",
82-
"company" : "abc corp"
83-
}';
87+
$contact_json = array(
88+
"email" => "[email protected]",
89+
"website" => "http://www.example.com",
90+
"company" => "abc corp"
91+
);
92+
93+
$contact_json = json_encode($contact_json);
8494

85-
curlWrap("contact", $contact_json, "PUT");
95+
curl_wrap("contact", $contact_json, "PUT");
8696
```
8797

8898
#### 2. Note
8999

90100
###### 2.1 To add Note
91101

92102
```php
93-
$note_json = '{
94-
"email" : "[email protected]",
95-
"subject" : "test",
96-
"description" : "note added"
97-
}';
103+
$note_json = array(
104+
"email" => "[email protected]",
105+
"subject" => "test",
106+
"description" => "note added"
107+
);
108+
109+
$note_json = json_encode($note_json);
98110

99-
curlWrap("note", $note_json, "POST");
111+
curl_wrap("note", $note_json, "POST");
100112
```
101113
###### 2.2 To fetch notes related to contact
102114

103115
```php
104-
$json = '{"email" : "[email protected]"}';
116+
$json = array("email" => "[email protected]");
105117

106-
curlWrap("note", $json, "GET");
118+
$json = json_encode($json);
119+
120+
curl_wrap("note", $json, "GET");
107121
```
108122

109123
#### 3. Score
110124

111125
###### 3.1 To add score to contact
112126

113127
```php
114-
$score_json = '{
115-
"email" : "[email protected]",
116-
"score" : "50"
117-
}';
128+
$score_json = array(
129+
"email" => "[email protected]",
130+
"score" => "50"
131+
);
132+
133+
$score_json = json_encode($score_json);
118134

119-
curlWrap("score", $score_json, "PUT");
135+
curl_wrap("score", $score_json, "PUT");
120136
```
121137
###### 3.2 To get the score related to particular contact
122138

123139
```php
124-
$json = '{"email" : "[email protected]"}';
140+
$json = array("email" => "[email protected]");
141+
142+
$json = json_encode($json);
125143

126-
curlWrap("score", $json, "GET");
144+
curl_wrap("score", $json, "GET");
127145
```
128146
###### 3.3 To subtract the score of contact
129147

130148
```php
131-
$subscore_json = '{"email" : "[email protected]", "score" : "-20"}';
149+
$subscore_json = array("email" => "[email protected]", "score" => "-20");
150+
151+
$subscore_json = json_encode($subscore_json);
132152

133-
curlWrap("score", $json, "PUT");
153+
curl_wrap("score", $json, "PUT");
134154
```
135155
#### 4. Task
136156

137157
###### 4.1 To add task to contact
138158

139159
```php
140-
$task_json = '{
141-
"email":"[email protected]",
142-
"type":"MEETING",
143-
"priority_type":"HIGH",
144-
"subject":"test"
145-
}';
160+
$task_json = array(
161+
"email" => "[email protected]",
162+
"type" => "MEETING",
163+
"priority_type" => "HIGH",
164+
"subject" => "test"
165+
);
146166

147-
curlWrap("tags", $tag_json, "POST");
167+
$task_json = json_encode($task_json);
168+
169+
curl_wrap("tags", $tag_json, "POST");
148170
```
149171
###### 4.2 To get tasks related to contact
150172

151173
```php
152-
$json = '{"email" : "[email protected]"}';
174+
$json = array("email" => "[email protected]");
175+
176+
$json = json_encode($json);
153177

154-
curlWrap("task", $json, "GET");
178+
curl_wrap("task", $json, "GET");
155179
```
156180
#### 5. Deal
157181

158182
###### 5.1 To add deal to contact
159183

160184
```php
161-
$deal_json = '{
162-
"email":"[email protected]",
163-
"name":"Test Deal",
164-
"description":"testing deal",
165-
"expected_value":"100",
166-
"milestone":"won",
167-
"probability":"5",
168-
"close_date":"1376047332"
169-
}';
185+
$deal_json = array(
186+
"email" => "[email protected]",
187+
"name" => "Test Deal",
188+
"description" => "testing deal",
189+
"expected_value" => "100",
190+
"milestone" => "won",
191+
"probability" => "5",
192+
"close_date" => "1376047332"
193+
);
194+
195+
$deal_json = json_encode($deal_json);
170196

171-
curlWrap("deal", $deal_json, "POST");
197+
curl_wrap("deal", $deal_json, "POST");
172198
```
173199

174200
###### 5.2 To get deals related to contact
175201

176202
```php
177-
$json = '{"email":"[email protected]"}';
203+
$json = array("email" => "[email protected]");
204+
205+
$json = json_encode($json);
178206

179-
curlWrap("deal", $json, "GET");
207+
curl_wrap("deal", $json, "GET");
180208
```
181209

182210
#### 6. Tags
183211

184212
###### 6.1 To add tags to contact
185213

186214
```php
187-
$tag_json = '{
188-
"email":"[email protected]",
189-
"tags":"tag1, tag2, tag3, tag4, tag5"
190-
}';
191-
192-
curlWrap("tags", $tag_json, "POST");
215+
$tag_json = array(
216+
"email" => "[email protected]",
217+
"tags" => "tag1, tag2, tag3, tag4, tag5"
218+
);
219+
220+
$tag_json = json_encode($tag_json);
221+
222+
curl_wrap("tags", $tag_json, "POST");
193223
```
194224
###### 6.2 To get tags related to contact
195225

196226
```php
197-
$json = '{"email":"[email protected]"}';
227+
$json = array("email" => "[email protected]");
228+
229+
$json = json_encode($json);
198230

199-
curlWrap("tags", $json, "GET");
231+
curl_wrap("tags", $json, "GET");
200232
```
201233
###### 6.3 To remove tags related to contact
202234

203235
```php
204-
$rm_tags_json = '{
205-
"email":"[email protected]",
206-
"tags":"tag3, tag4"
207-
}';
236+
$rm_tags_json = array(
237+
"email" => "[email protected]",
238+
"tags" => "tag3, tag4"
239+
);
240+
241+
$rm_tags_json = json_encode($rm_tags_json);
208242

209-
curlWrap("tags", $rm_tags_json, "PUT");
243+
curl_wrap("tags", $rm_tags_json, "PUT");
210244
```
211-
For example implementation of all available API refer to [testagile.php](https://github.com/agilecrm/php-api/blob/master/testagile.php).
245+
For example implementation of all available API refer to [sample.php](https://github.com/agilecrm/php-api/blob/master/sample.php).

curlwrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
define("apikey", "your_agile_api_key");
33
define("domain", "your_agile_subdomain");
44

5-
function curlWrap ($subject, $json, $action)
5+
function curl_wrap ($subject, $json, $action)
66
{
77
$ch = curl_init();
88
curl_setopt_array($ch, array(

0 commit comments

Comments
 (0)