PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 2.9.15
Brevo – Email, SMS, Web Push, Chat, and more. v2.9.15
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / inc / mailin.php
mailin / inc Last commit date
templates 6 years ago function.wp_mail.php 8 years ago index.php 8 years ago mailin.php 6 years ago sendinblue.php 9 years ago sib-api-manager.php 6 years ago sib-form-preview.php 8 years ago sib-sms-code.php 8 years ago table-forms.php 8 years ago
mailin.php
1010 lines
1 <?php
2
3 /**
4 * Sendinblue REST client
5 */
6
7 class SibMailin
8 {
9 public $api_key;
10 public $base_url;
11 public $curl_opts = array();
12 public function __construct($base_url,$api_key)
13 {
14 if(!function_exists('curl_init'))
15 {
16 throw new Exception('SibMailin requires CURL module');
17 }
18 $this->base_url = $base_url;
19 $this->api_key = $api_key;
20 }
21 /**
22 * Do CURL request with authorization
23 */
24 private function do_request($resource,$method,$input)
25 {
26 $called_url = $this->base_url."/".$resource;
27 $ssl_verify = true;
28 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
29 // Windows only over-ride
30 $ssl_verify = false;
31 }
32
33 $args = array(
34 'method' => $method,
35 'sslverify' => $ssl_verify,
36 'headers' => array(
37 'api-key' => $this->api_key,
38 'Content-Type'=> 'application/json'),
39 );
40 $args['body'] = $input;
41
42 $response = wp_remote_request($called_url, $args);
43 $data = wp_remote_retrieve_body($response);
44
45 return json_decode($data,true);
46 }
47 public function get($resource,$input)
48 {
49 return $this->do_request($resource,"GET",$input);
50 }
51 public function put($resource,$input)
52 {
53 return $this->do_request($resource,"PUT",json_encode($input));
54 }
55 public function post($resource,$input)
56 {
57 return $this->do_request($resource,"POST",json_encode($input));
58 }
59 public function delete($resource,$input)
60 {
61 return $this->do_request($resource,"DELETE",$input);
62 }
63
64 /*
65 Get Account.
66 No input required
67 */
68 public function get_account()
69 {
70 return $this->get("account","");
71 }
72
73 /*
74 Get SMTP details.
75 No input required
76 */
77 public function get_smtp_details()
78 {
79 return $this->get("account/smtpdetail","");
80 }
81
82 /*
83 Create Child Account.
84 @param {Array} data contains php array with key value pair.
85 @options data {String} child_email: Email address of Reseller child [Mandatory]
86 @options data {String} password: Password of Reseller child to login [Mandatory]
87 @options data {String} company_org: Name of Reseller child’s company [Mandatory]
88 @options data {String} first_name: First name of Reseller child [Mandatory]
89 @options data {String} last_name: Last name of Reseller child [Mandatory]
90 @options data {Array} credits: Number of email & sms credits respectively, which will be assigned to the Reseller child’s account [Optional]
91 - email_credit {Integer} number of email credits
92 - sms_credit {Integer} Number of sms credts
93 @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
94 */
95 public function create_child_account($data)
96 {
97 return $this->post("account",$data);
98 }
99
100 /*
101 Update Child Account.
102 @param {Array} data contains php array with key value pair.
103 @options data {String} auth_key: 16 character authorization key of Reseller child to be modified [Mandatory]
104 @options data {String} company_org: Name of Reseller child’s company [Optional]
105 @options data {String} first_name: First name of Reseller child [Optional]
106 @options data {String} last_name: Last name of Reseller child [Optional]
107 @options data {String} password: Password of Reseller child to login [Optional]
108 @options data {Array} associate_ip: Associate dedicated IPs to reseller child. You can use commas to separate multiple IPs [Optional]
109 @options data {Array} disassociate_ip: Disassociate dedicated IPs from reseller child. You can use commas to separate multiple IPs [Optional]
110 */
111 public function update_child_account($data)
112 {
113 return $this->put("account",$data);
114 }
115
116 /*
117 Delete Child Account.
118 @param {Array} data contains php array with key value pair.
119 @options data {String} auth_key: 16 character authorization key of Reseller child to be deleted [Mandatory]
120 */
121 public function delete_child_account($data)
122 {
123 return $this->delete("account/".$data['auth_key'],"");
124 }
125
126 /*
127 Get Reseller child Account.
128 @param {Array} data contains php array with key value pair.
129 @options data {String} auth_key: 16 character authorization key of Reseller child. Example : To get the details of more than one child account, use, {"key1":"abC01De2fGHI3jkL","key2":"mnO45Pq6rSTU7vWX"} [Mandatory]
130 */
131 public function get_reseller_child($data)
132 {
133 return $this->post("account/getchildv2",$data);
134 }
135
136 /*
137 Add/Remove Reseller child's Email/Sms credits.
138 @param {Array} data contains php array with key value pair.
139 @options data {String} auth_key: 16 character authorization key of Reseller child to modify credits [Mandatory]
140 @options data {Array} add_credit: Number of email & sms credits to be added. You can assign either email or sms credits, one at a time other will remain 0. [Mandatory: if rmv_credit is empty]
141 - email_credit {Integer} number of email credits
142 - sms_credit {Integer} Number of sms credts
143 @options data {Array} rmv_credit: Number of email & sms credits to be removed. You can assign either email or sms credits, one at a time other will remain 0. [Mandatory: if add_credits is empty]
144 - email_credit {Integer} number of email credits
145 - sms_credit {Integer} Number of sms credts
146 */
147 public function add_remove_child_credits($data)
148 {
149 return $this->post("account/addrmvcredit",$data);
150 }
151
152 /*
153 Get a particular campaign detail.
154 @param {Array} data contains php array with key value pair.
155 @options data {Integer} id: Unique Id of the campaign [Mandatory]
156 */
157 public function get_campaign_v2($data)
158 {
159 return $this->get("campaign/".$data['id']."/detailsv2","");
160 }
161
162 /*
163 Get all campaigns detail.
164 @param {Array} data contains php array with key value pair.
165 @options data {String} type: Type of campaign. Possible values – classic, trigger, sms, template ( case sensitive ) [Optional]
166 @options data {String} status: Status of campaign. Possible values – draft, sent, archive, queued, suspended, in_process, temp_active, temp_inactive ( case sensitive ) [Optional]
167 @options data {Integer} page: Maximum number of records per request is 500, if there are more than 500 campaigns then you can use this parameter to get next 500 results [Optional]
168 @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
169 */
170 public function get_campaigns_v2($data)
171 {
172 return $this->get("campaign/detailsv2",$data);
173 }
174
175 /*
176 Create and Schedule your campaigns. It returns the ID of the created campaign.
177 @param {Array} data contains php array with key value pair.
178 @options data {String} category: Tag name of the campaign [Optional]
179 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
180 @options data {String} name: Name of the campaign [Mandatory]
181 @options data {String} bat: Email address for test mail [Optional]
182 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty]
183 @options data {String} html_url: Url which content is the body of content [Mandatory: if html_content is empty]
184 @options data {Array} listid: These are the lists to which the campaign has been sent [Mandatory: if scheduled_date is not empty]
185 @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
186 @options data {String} subject: Subject of the campaign [Mandatory]
187 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
188 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
189 @options data {String} to_field: This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM] To use the contact attributes here, these should already exist in Sendinblue account [Optional]
190 @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
191 @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
192 @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded, in the email [Optional]
193 @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
194 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
195
196 */
197 public function create_campaign($data)
198 {
199 return $this->post("campaign",$data);
200 }
201
202 /*
203 Update your campaign.
204 @param {Array} data contains php array with key value pair.
205 @options data {Integer} id: Id of campaign to be modified [Mandatory]
206 @options data {String} category: Tag name of the campaign [Optional]
207 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
208 @options data {String} name: Name of the campaign [Optional]
209 @options data {String} bat: Email address for test mail [Optional]
210 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Optional]
211 @options data {String} html_url: Url which content is the body of content [Optional]
212 @options data {Array} listid These are the lists to which the campaign has been sent [Mandatory: if scheduled_date is not empty]
213 @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
214 @options data {String} subject: Subject of the campaign.
215 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
216 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
217 @options data {String} to_field: This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in Sendinblue account [Optional]
218 @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
219 @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
220 @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded, in the email [Optional]
221 @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
222 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
223 */
224 public function update_campaign($data)
225 {
226 $id = $data['id'];
227 unset($data['id']);
228 return $this->put("campaign/".$id,$data);
229 }
230
231 /*
232 Delete your campaigns.
233 @param {Array} data contains php array with key value pair.
234 @options data {Integer} id: Id of campaign to be deleted [Mandatory]
235 */
236 public function delete_campaign($data)
237 {
238 return $this->delete("campaign/".$data['id'],"");
239 }
240
241 /*
242 Send report of Sent and Archived campaign.
243 @param {Array} data contains php array with key value pair.
244 @options data {Integer} id: Id of campaign to send its report [Mandatory]
245 @options data {String} lang: Language of email content. Possible values – fr (default), en, es, it & pt [Optional]
246 @options data {String} email_subject: Message subject [Mandatory]
247 @options data {Array} email_to: Email address of the recipient(s). Example: "test@example.net". You can use commas to separate multiple recipients [Mandatory]
248 @options data {String} email_content_type: Body of the message in text/HTML version. Possible values – text & html [Mandatory]
249 @options data {Array} email_bcc: Same as email_to but for Bcc [Optional]
250 @options data {Array} email_cc: Same as email_to but for Cc [Optional]
251 @options data {String} email_body: Body of the message [Mandatory]
252 */
253 public function campaign_report_email($data)
254 {
255 $id = $data['id'];
256 unset($data['id']);
257 return $this->post("campaign/".$id."/report",$data);
258 }
259
260 /*
261 Export the recipients of a specified campaign.
262 @param {Array} data contains php array with key value pair.
263 @options data {Integer} id: Id of campaign to export its recipients [Mandatory]
264 @options data {String} notify_url: URL that will be called once the export process is finished [Mandatory]
265 @options data {String} type: Type of recipients. Possible values – all, non_clicker, non_opener, clicker, opener, soft_bounces, hard_bounces & unsubscribes [Mandatory]
266 */
267 public function campaign_recipients_export($data)
268 {
269 $id = $data['id'];
270 unset($data['id']);
271 return $this->post("campaign/".$id."/recipients",$data);
272 }
273
274 /*
275 Get the Campaign name, subject and share link of the classic type campaigns only which are sent, for those which are not sent and the rest of campaign types like trigger, template & sms, will return an error message of share link not available.
276 @param {Array} data contains php array with key value pair.
277 @options data {Array} camp_ids: Id of campaign to get share link. You can use commas to separate multiple ids [Mandatory]
278 */
279
280 public function share_campaign($data)
281 {
282 return $this->post("campaign/sharelinkv2",$data);
283 }
284
285 /*
286 Send a Test Campaign.
287 @param {Array} data contains php array with key value pair.
288 @options data {Integer} id: Id of the campaign [Mandatory]
289 @options data {Array} emails: Email address of recipient(s) existing in the one of the lists & should not be blacklisted. Example: "test@example.net". You can use commas to separate multiple recipients [Mandatory]
290 */
291 public function send_bat_email($data)
292 {
293 $id = $data['id'];
294 unset($data['id']);
295 return $this->post("campaign/".$id."/test",$data);
296 }
297
298 /*
299 Update the Campaign status.
300 @param {Array} data contains php array with key value pair.
301 @options data {Integer} id: Id of campaign to update its status [Mandatory]
302 @options data {String} status: Types of status. Possible values – suspended, archive, darchive, sent, queued, replicate and replicate_template ( case sensitive ) [Mandatory]
303 */
304 public function update_campaign_status($data)
305 {
306 $id = $data['id'];
307 unset($data['id']);
308 return $this->put("campaign/".$id."/updatecampstatus",$data);
309 }
310
311 /*
312 Create and schedule your Trigger campaigns.
313 @param {Array} data contains php array with key value pair.
314 @options data {String} category: Tag name of the campaign [Optional]
315 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
316 @options data {String} trigger_name: Name of the campaign [Mandatory]
317 @options data {String} bat: Email address for test mail [Optional]
318 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty]
319 @options data {String} html_url: Url which content is the body of content [Mandatory: if html_content is empty]
320 @options data {Array} listid: These are the lists to which the campaign has been sent [Mandatory: if scheduled_date is not empty]
321 @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
322 @options data {String} subject: Subject of the campaign [Mandatory]
323 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
324 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
325 @options data {String} to_field: This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in Sendinblue account [Optional]
326 @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
327 @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1. recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1 means contact can receive the same Trigger campaign several times [Optional]
328 @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
329 @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded, in the email [Optional]
330 @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
331 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
332 */
333 public function create_trigger_campaign($data)
334 {
335 return $this->post("campaign",$data);
336 }
337
338 /*
339 Update and schedule your Trigger campaigns.
340 @param {Array} data contains php array with key value pair.
341 @options data {Integer} id: Id of Trigger campaign to be modified [Mandatory]
342 @options data {String} category: Tag name of the campaign [Optional]
343 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
344 @options data {String} trigger_name: Name of the campaign [Mandatory]
345 @options data {String} bat Email address for test mail [Optional]
346 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty]
347 @options data {String} html_url: Url which content is the body of content [Mandatory: if html_content is empty]
348 @options data {Array} listid: These are the lists to which the campaign has been sent [Mandatory: if scheduled_date is not empty]
349 @options data {String} scheduled_date: The day on which the campaign is supposed to run[Optional]
350 @options data {String} subject: Subject of the campaign [Mandatory]
351 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients, please make sure that the sender details are defined here, and in case of no sender, you can add them also via API & for Shared IP clients, if sender exists]
352 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
353 @options data {String} to_field: This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in Sendinblue account [Optional]
354 @options data {Array} exclude_list: These are the lists which must be excluded from the campaign [Optional]
355 @options data {Integer} recurring: Type of trigger campaign. Possible values = 0 (default) & 1. recurring = 0 means contact can receive the same Trigger campaign only once, & recurring = 1 means contact can receive the same Trigger campaign several times [Optional]
356 @options data {String} attachment_url: Provide the absolute url of the attachment [Optional]
357 @options data {Integer} inline_image: Status of inline image. Possible values = 0 (default) & 1. inline_image = 0 means image can’t be embedded, & inline_image = 1 means image can be embedded, in the email [Optional]
358 @options data {Integer} mirror_active: Status of mirror links in campaign. Possible values = 0 & 1 (default). mirror_active = 0 means mirror links are deactivated, & mirror_active = 1 means mirror links are activated, in the campaign [Optional]
359 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
360 */
361 public function update_trigger_campaign($data)
362 {
363 $id = $data['id'];
364 unset($data['id']);
365 return $this->put("campaign/".$id,$data);
366 }
367
368 /*
369 Get all folders detail.
370 @param {Array} data contains php array with key value pair.
371 @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 folders then you can use this parameter to get next 50 results [Mandatory]
372 @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
373 */
374 public function get_folders($data)
375 {
376 return $this->get("folder",$data);
377 }
378
379 /*
380 Get a particular folder detail.
381 @param {Array} data contains php array with key value pair.
382 @options data {Integer} id: Id of folder to get details [Mandatory]
383 */
384 public function get_folder($data)
385 {
386 return $this->get("folder/".$data['id'],"");
387 }
388
389 /*
390 Create a new folder.
391 @param {Array} data contains php array with key value pair.
392 @options data {String} name: Desired name of the folder to be created [Mandatory]
393 */
394 public function create_folder($data)
395 {
396 return $this->post("folder",$data);
397 }
398
399 /*
400 Delete a specific folder information.
401 @param {Array} data contains php array with key value pair.
402 @options data {Integer} id: Id of folder to be deleted [Mandatory]
403 */
404 public function delete_folder($data)
405 {
406 return $this->delete("folder/".$data['id'],"");
407 }
408
409 /*
410 Update an existing folder.
411 @param {Array} data contains php array with key value pair.
412 @options data {Integer} id: Id of folder to be modified [Mandatory]
413 @options data {String} name: Desired name of the folder to be modified [Mandatory]
414 */
415 public function update_folder($data)
416 {
417 $id = $data['id'];
418 unset($data['id']);
419 return $this->put("folder/".$id,$data);
420 }
421
422 /*
423 Get all lists detail.
424 @param {Array} data contains php array with key value pair.
425 @options data {Integer} list_parent: This is the existing folder id & can be used to get all lists belonging to it [Optional]
426 @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
427 @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
428 */
429 public function get_lists($data)
430 {
431 return $this->get("list",$data);
432 }
433
434 /*
435 Get a particular list detail.
436 @param {Array} data contains php array with key value pair.
437 @options data {Integer} id: Id of list to get details [Mandatory]
438 */
439 public function get_list($data)
440 {
441 return $this->get("list/".$data['id'],"");
442 }
443
444 /*
445 Create a new list.
446 @param {Array} data contains php array with key value pair.
447 @options data {String} list_name: Desired name of the list to be created [Mandatory]
448 @options data {Integer} list_parent: Folder ID [Mandatory]
449 */
450 public function create_list($data)
451 {
452 return $this->post("list",$data);
453 }
454
455 /*
456 Update a list.
457 @param {Array} data contains php array with key value pair.
458 @options data {Integer} id: Id of list to be modified [Mandatory]
459 @options data {String} list_name: Desired name of the list to be modified [Optional]
460 @options data {Integer} list_parent: Folder ID [Mandatory]
461 */
462 public function update_list($data)
463 {
464 $id = $data['id'];
465 unset($data['id']);
466 return $this->put("list/".$id,$data);
467 }
468
469 /*
470 Delete a specific list.
471 @param {Array} data contains php array with key value pair.
472 @options data {Integer} id: Id of list to be deleted [Mandatory]
473 */
474 public function delete_list($data)
475 {
476 return $this->delete("list/".$data['id'],"");
477 }
478
479 /*
480 Display details of all users for the given lists.
481 @param {Array} data contains php array with key value pair.
482 @options data {Array} listids: These are the list ids to get their data. The ids found will display records [Mandatory]
483 @options data {String} timestamp: This is date-time filter to fetch modified user records >= this time. Valid format Y-m-d H:i:s. Example: "2015-05-22 14:30:00" [Optional]
484 @options data {Integer} page: Maximum number of records per request is 500, if in your list there are more than 500 users then you can use this parameter to get next 500 results [Optional]
485 @options data {Integer} page_limit: This should be a valid number between 1-500 [Optional]
486 */
487 public function display_list_users($data)
488 {
489 return $this->post("list/display",$data);
490 }
491
492 /*
493 Add already existing users in the Sendinblue contacts to the list.
494 @param {Array} data contains php array with key value pair.
495 @options data {Integer} id: Id of list to link users in it [Mandatory]
496 @options data {Array} users: Email address of the already existing user(s) in the Sendinblue contacts. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
497 */
498
499 public function add_users_list($data)
500 {
501 $id = $data['id'];
502 unset($data['id']);
503 return $this->post("list/".$id."/users",$data);
504 }
505
506 /*
507 Delete already existing users in the Sendinblue contacts from the list.
508 @param {Array} data contains php array with key value pair.
509 @options data {Integer} id: Id of list to unlink users from it [Mandatory]
510 @options data {Array} users: Email address of the already existing user(s) in the Sendinblue contacts to be modified. Example: "test@example.net". You can use commas to separate multiple users [Mandatory]
511 */
512 public function delete_users_list($data)
513 {
514 $id = $data['id'];
515 unset($data['id']);
516 return $this->delete("list/".$id."/delusers",$data);
517 }
518
519 /*
520 Access all the attributes information under the account.
521 No input required
522 */
523 public function get_attributes()
524 {
525 return $this->get("attribute","");
526 }
527
528 /*
529 Access the specific type of attribute information.
530 @param {Array} data contains php array with key value pair.
531 @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global [Optional]
532 */
533 public function get_attribute($data)
534 {
535 return $this->get("attribute/".$data['type'],"");
536 }
537
538 /*
539 Create an Attribute.
540 @param {Array} data contains php array with key value pair.
541 @options data {String} type: Type of attribute. Possible values – normal, transactional, category, calculated & global ( case sensitive ) [Mandatory]
542 @options data {Array} data: The name and data type of ‘normal’ & ‘transactional’ attribute to be created in your Sendinblue account. It should be sent as an associative array. Example: array(‘ATTRIBUTE_NAME1′ => ‘DATA_TYPE1′, ‘ATTRIBUTE_NAME2’=> ‘DATA_TYPE2′).
543 The name and data value of ‘category’, ‘calculated’ & ‘global’, should be sent as JSON string. Example: ‘[{ "name":"ATTRIBUTE_NAME1", "value":"Attribute_value1" }, { "name":"ATTRIBUTE_NAME2", "value":"Attribute_value2" }]’. You can use commas to separate multiple attributes [Mandatory]
544 */
545 public function create_attribute($data)
546 {
547 return $this->post("attribute/",$data);
548 }
549
550 /*
551 Delete a specific type of attribute information.
552 @param {Array} data contains php array with key value pair.
553 @options data {Integer} type: Type of attribute to be deleted [Mandatory]
554 */
555 public function delete_attribute($type,$data)
556 {
557 $type = $data['type'];
558 unset($data['type']);
559 return $this->post("attribute/".$type,$data);
560 }
561
562 /*
563 Create a new user if an email provided as input, doesn’t exists in the contact list of your Sendinblue account, otherwise it will update the existing user.
564 @param {Array} data contains php array with key value pair.
565 @options data {String} email: Email address of the user to be created in Sendinblue contacts. Already existing email address of user in the Sendinblue contacts to be modified [Mandatory]
566 @options data {Array} attributes: The name of attribute present in your Sendinblue account. It should be sent as an associative array. Example: array("NAME"=>"name"). You can use commas to separate multiple attributes [Optional]
567 @options data {Integer} blacklisted: This is used to blacklist/ Unblacklist a user. Possible values – 0 & 1. blacklisted = 1 means user has been blacklisted [Optional]
568 @options data {Array} listid: The list id(s) to be linked from user [Optional]
569 @options data {Array} listid_unlink: The list id(s) to be unlinked from user [Optional]
570 @options data {Array} blacklisted_sms: This is used to blacklist/ Unblacklist a user’s SMS number. Possible values – 0 & 1. blacklisted_sms = 1 means user’s SMS number has been blacklisted [Optional]
571 */
572 public function create_update_user($data)
573 {
574 return $this->post("user/createdituser",$data);
575 }
576
577 /*
578 Get Access a specific user Information.
579 @param {Array} data contains php array with key value pair.
580 @options data {String} email: Email address of the already existing user in the Sendinblue contacts [Mandatory]
581 */
582 public function get_user($data)
583 {
584 return $this->get("user/".$data['email'],"");
585 }
586
587 /*
588 Unlink existing user from all lists.
589 @param {Array} data contains php array with key value pair.
590 @options data {String} email: Email address of the already existing user in the Sendinblue contacts to be unlinked from all lists [Mandatory]
591 */
592 public function delete_user($data)
593 {
594 return $this->delete("user/".$data['email'],"");
595 }
596
597 /*
598 Import Users Information.
599 @param {Array} data contains php array with key value pair.
600 @options data {String} url: The URL of the file to be imported. Possible file types – .txt, .csv [Mandatory: if body is empty]
601 @options data {String} body: The Body with csv content to be imported. Example: ‘NAME;SURNAME;EMAIL\n"Name1";"Surname1";"example1@example.net"\n"Name2";"Surname2";"example2@example.net"‘, where \n separates each user data. You can use semicolon to separate multiple attributes [Mandatory: if url is empty]
602 @options data {Array} listids: These are the list ids in which the the users will be imported [Mandatory: if name is empty]
603 @options data {String} notify_url: URL that will be called once the import process is finished [Optional] In notify_url, we are sending the content using POST method
604 @options data {String} name: This is new list name which will be created first & then users will be imported in it [Mandatory: if listids is empty]
605 @options data {Integer} list_parent: This is the existing folder id & can be used with name parameter to make newly created list’s desired parent [Optional]
606 */
607 public function import_users($data)
608 {
609 return $this->post("user/import",$data);
610 }
611
612 /*
613 Export Users Information.
614 @param {Array} data contains php array with key value pair.
615 @options data {String} export_attrib: The name of attribute present in your Sendinblue account. You can use commas to separate multiple attributes. Example: "EMAIL,NAME,SMS" [Optional]
616 @options data {String} filter: Filter can be added to export users. Example: "{\"blacklisted\":1}", will export all blacklisted users [Mandatory]
617 @options data {String} notify_url: URL that will be called once the export process is finished [Optional]
618 */
619 public function export_users($data)
620 {
621 return $this->post("user/export",$data);
622 }
623
624 /*
625 Get all the processes information under the account.
626 @param {Array} data contains php array with key value pair.
627 @options data {Integer} page: Maximum number of records per request is 50, if there are more than 50 processes then you can use this parameter to get next 50 results [Mandatory]
628 @options data {Integer} page_limit: This should be a valid number between 1-50 [Mandatory]
629 */
630 public function get_processes($data)
631 {
632 return $this->get("process",$data);
633 }
634
635 /*
636 Get the process information.
637 @param {Array} data contains php array with key value pair.
638 @options data {Integer} id: Id of process to get details [Mandatory]
639 */
640 public function get_process($data)
641 {
642 return $this->get("process/".$data['id'],"");
643 }
644
645 /*
646 To retrieve details of all webhooks.
647 @param {Array} data contains php array with key value pair.
648 @options data {String} is_plat: Flag to get webhooks. Possible values – 0 & 1. Example: to get Transactional webhooks, use $is_plat=0, to get Marketing webhooks, use $is_plat=1, & to get all webhooks, use $is_plat="" [Optional]
649 */
650 public function get_webhooks($data)
651 {
652 return $this->get("webhook",$data);
653 }
654
655 /*
656 To retrieve details of any particular webhook.
657 @param {Array} data contains php array with key value pair.
658 @options data {Integer} id: Id of webhook to get details [Mandatory]
659 */
660 public function get_webhook($data)
661 {
662 return $this->get("webhook/".$data['id'],"");
663 }
664
665 /*
666 Create a Webhook.
667 @param {Array} data contains php array with key value pair.
668 @options data {String} url: URL that will be triggered by a webhook [Mandatory]
669 @options data {String} description: Webook description [Optional]
670 @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
671 @options data {Integer} is_plat: Flag to create webhook type. Possible values – 0 (default) & 1. Example: to create Transactional webhooks, use $is_plat=0, & to create Marketing webhooks, use $is_plat=1 [Optional]
672 */
673 public function create_webhook($data)
674 {
675 return $this->post("webhook",$data);
676 }
677
678 /*
679 Delete a webhook.
680 @param {Array} data contains php array with key value pair.
681 @options data {Integer} id: Id of webhook to be deleted [Mandatory]
682 */
683 public function delete_webhook($data)
684 {
685 return $this->delete("webhook/".$data['id'],"");
686 }
687
688 /*
689 Update a webhook.
690 @param {Array} data contains php array with key value pair.
691 @options data {Integer} id: Id of webhook to be modified [Mandatory]
692 @options data {String} url: URL that will be triggered by a webhook [Mandatory]
693 @options data {String} description: Webook description [Optional]
694 @options data {Array} events: Set of events. You can use commas to separate multiple events. Possible values for Transcational webhook – request, delivered, hard_bounce, soft_bounce, blocked, spam, invalid_email, deferred, click, & opened and Possible Values for Marketing webhook – spam, opened, click, hard_bounce, unsubscribe, soft_bounce & list_addition ( case sensitive ) [Mandatory]
695 */
696 public function update_webhook($data)
697 {
698 $id = $data['id'];
699 unset($data['id']);
700 return $this->put("webhook/".$id,$data);
701 }
702
703 /*
704 Get Access of created senders information.
705 @param {Array} data contains php array with key value pair.
706 @options data {String} option: Options to get senders. Possible options – IP-wise, & Domain-wise ( only for dedicated IP clients ). Example: to get senders with specific IP, use $option=’1.2.3.4′, to get senders with specific domain use, $option=’domain.com’, & to get all senders, use $option="" [Optional]
707 */
708 public function get_senders($data)
709 {
710 return $this->get("advanced",$data);
711 }
712
713 /*
714 Create your Senders.
715 @param {Array} data contains php array with key value pair.
716 @options data {String} name: Name of the sender [Mandatory]
717 @options data {String} email: Email address of the sender [Mandatory]
718 @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
719 */
720 public function create_sender($data)
721 {
722 return $this->post("advanced",$data);
723 }
724
725 /*
726 Update your Senders.
727 @param {Array} data contains php array with key value pair.
728 @options data {Integer} id: Id of sender to be modified [Mandatory]
729 @options data {String} name: Name of the sender [Mandatory]
730 @options data {Array} ip_domain: Pass pipe ( | ) separated Dedicated IP and its associated Domain. Example: "1.2.3.4|mydomain.com". You can use commas to separate multiple ip_domain’s [Mandatory: Only for Dedicated IP clients, for Shared IP clients, it should be kept blank]
731 */
732 public function update_sender($data)
733 {
734 $id = $data['id'];
735 unset($data['id']);
736 return $this->put("advanced/".$id,$data);
737 }
738
739 /*
740 Delete your Sender Information.
741 @param {Array} data contains php array with key value pair.
742 @options data {Integer} id: Id of sender to be deleted [Mandatory]
743 */
744 public function delete_sender($data)
745 {
746 return $this->delete("advanced/".$data['id'],"");
747 }
748
749 /*
750 Send Transactional Email.
751 @param {Array} data contains php array with key value pair.
752 @options data {Array} to: Email address of the recipient(s). It should be sent as an associative array. Example: array("to@example.net"=>"to whom"). You can use commas to separate multiple recipients [Mandatory]
753 @options data {String} subject: Message subject [Mandatory]
754 @options data {Array} from Email address for From header. It should be sent as an array. Example: array("from@email.com","from email") [Mandatory]
755 @options data {String} html: Body of the message. (HTML version) [Mandatory]. To send inline images, use <img src="{YourFileName.Extension}" alt="image" border="0" >, the 'src' attribute value inside {} (curly braces) should be same as the filename used in 'inline_image' parameter
756 @options data {String} text: Body of the message. (text version) [Optional]
757 @options data {Array} cc: Same as to but for Cc. Example: array("cc@example.net","cc whom") [Optional]
758 @options data {Array} bcc: Same as to but for Bcc. Example: array("bcc@example.net","bcc whom") [Optional]
759 @options data {Array} replyto: Same as from but for Reply To. Example: array("from@email.com","from email") [Optional]
760 @options data {Array} attachment: Provide the absolute url of the attachment/s. Possible extension values = gif, png, bmp, cgm, jpg, jpeg, txt, css, shtml, html, htm, csv, zip, pdf, xml, doc, xls, ppt, tar, and ez. To send attachment/s generated on the fly you have to pass your attachment/s filename & its base64 encoded chunk data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple attachments [Optional]
761 @options data {Array} headers: The headers will be sent along with the mail headers in original email. Example: array("Content-Type"=>"text/html; charset=iso-8859-1"). You can use commas to separate multiple headers [Optional]
762 @options data {Array} inline_image: Pass your inline image/s filename & its base64 encoded chunk data as an associative array. Example: array("YourFileName.Extension"=>"Base64EncodedChunkData"). You can use commas to separate multiple inline images [Optional]
763 */
764 public function send_email($data)
765 {
766 return $this->post("email",$data);
767 }
768
769 /*
770 Aggregate / date-wise report of the Sendinblue SMTP account.
771 @param {Array} data contains php array with key value pair.
772 @options data {Integer} aggregate: This is used to indicate, you are interested in all-time totals. Possible values – 0 & 1. aggregate = 0 means it will not aggregate records, and will show stats per day/date wise [Optional]
773 @options data {String} start_date: The start date to look up statistics. Date must be in YYYY-MM-DD format and should be before the end_date [Optional]
774 @options data {String} end_date: The end date to look up statistics. Date must be in YYYY-MM-DD format and should be after the start_date [Optional]
775 @options data {Integer} days: Number of days in the past to include statistics ( Includes today ). It must be an integer greater than 0 [Optional]
776 @options data {String} tag: The tag you will specify to retrieve detailed stats. It must be an existing tag that has statistics [Optional]
777 */
778 public function get_statistics($data)
779 {
780 return $this->post("statistics",$data);
781 }
782
783 /*
784 Get Email Event report.
785 @param {Array} data contains php array with key value pair.
786 @options data {Integer} limit: To limit the number of results returned. It should be an integer [Optional]
787 @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD format and should be before the end_date [Optional]
788 @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD format and should be after the start_date [Optional]
789 @options data {Integer} offset: Beginning point in the list to retrieve from. It should be an integer [Optional]
790 @options data {String} date: Specific date to get its report. Date must be in YYYY-MM-DD format and should be earlier than todays date [Optional]
791 @options data {Integer} days: Number of days in the past (includes today). If specified, must be an integer greater than 0 [Optional]
792 @options data {String} email: Email address to search report for [Optional]
793 */
794 public function get_report($data)
795 {
796 return $this->post("report",$data);
797 }
798
799 /*
800 Delete any hardbounce, which actually would have been blocked due to some temporary ISP failures.
801 @param {Array} data contains php array with key value pair.
802 @options data {String} start_date: The start date to get report from. Date must be in YYYY-MM-DD format and should be before the end_date [Optional]
803 @options data {String} end_date: The end date to get report till date. Date must be in YYYY-MM-DD format and should be after the start_date [Optional]
804 @options data {String} email: Email address to delete its bounces [Optional]
805 */
806 public function delete_bounces($data)
807 {
808 return $this->post("bounces",$data);
809 }
810
811 /*
812 Send templates created on Sendinblue, through Sendinblue SMTP (transactional mails).
813 @param {Array} data contains php array with key value pair.
814 @options data {Integer} id: Id of the template created on Sendinblue account [Mandatory]
815 @options data {String} to: Email address of the recipient(s). You can use pipe ( | ) to separate multiple recipients. Example: "to-example@example.net|to2-example@example.net" [Mandatory]
816 @options data {String} cc: Same as to but for Cc [Optional]
817 @options data {String} bcc: Same as to but for Bcc [Optional]
818 @options data {Array} attrv The name of attribute present in your Sendinblue account. It should be sent as an associative array. Example: array("NAME"=>"name"). You can use commas to separate multiple attributes [Optional]
819 @options data {String} attachment_url: Provide the absolute url of the attachment. Url not allowed from local machine. File must be hosted somewhere [Optional]
820 @options data {Array} attachment: To send attachment/s generated on the fly you have to pass your attachment/s filename & its base64 encoded chunk data as an associative array [Optional]
821 */
822 public function send_transactional_template($data)
823 {
824 $id = $data['id'];
825 unset($data['id']);
826 return $this->put("template/".$id,$data);
827 }
828
829 /*
830 Create a Template.
831 @param {Array} data contains php array with key value pair.
832 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
833 @options data {String} template_name: Name of the Template [Mandatory]
834 @options data {String} bat: Email address for test mail [Optional]
835 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty]
836 @options data {String} html_url Url: which content is the body of content [Mandatory: if html_content is empty]
837 @options data {String} subject: Subject of the campaign [Mandatory]
838 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
839 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
840 @options data {String} to_fieldv This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in Sendinblue account [Optional]
841 @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
842 @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
843 */
844 public function create_template($data)
845 {
846 return $this->post("template",$data);
847 }
848
849 /*
850 Update a Template.
851 @param {Array} data contains php array with key value pair.
852 @options data {Integer} id: Id of Template to be modified [Mandatory]
853 @options data {String} from_name: Sender name from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
854 @options data {String} template_name: Name of the Template [Mandatory]
855 @options data {String} bat: Email address for test mail [Optional]
856 @options data {String} html_content: Body of the content. The HTML content field must have more than 10 characters [Mandatory: if html_url is empty]
857 @options data {String} html_url: Url which content is the body of content [Mandatory: if html_content is empty]
858 @options data {String} subject: Subject of the campaign [Mandatory]
859 @options data {String} from_email: Sender email from which the campaign emails are sent [Mandatory: for Dedicated IP clients & for Shared IP clients, if sender exists]
860 @options data {String} reply_to: The reply to email in the campaign emails [Optional]
861 @options data {String} to_field: This is to personalize the «To» Field. If you want to include the first name and last name of your recipient, add [PRENOM] [NOM]. To use the contact attributes here, these should already exist in Sendinblue account [Optional]
862 @options data {Integer} status: Status of template. Possible values = 0 (default) & 1. status = 0 means template is inactive, & status = 1 means template is active [Optional]
863 @options data {Integer} attachment: Status of attachment. Possible values = 0 (default) & 1. attach = 0 means an attachment can’t be sent, & attach = 1 means an attachment can be sent, in the email [Optional]
864 */
865 public function update_template($data)
866 {
867 $id = $data['id'];
868 unset($data['id']);
869 return $this->put("template/".$id,$data);
870 }
871
872 /*
873 Send a transactional SMS.
874 @param {Array} data contains php array with key value pair.
875 @options data {String} to: The mobile number to send SMS to with country code [Mandatory]
876 @options data {String} from: The name of the sender. The number of characters is limited to 11 (alphanumeric format) [Mandatory]
877 @options data {String} text: The text of the message. The maximum characters used per SMS is 160, if used more than that, it will be counted as more than one SMS [Mandatory]
878 @options data {String} web_url: The web URL that can be called once the message is successfully delivered [Optional]
879 @options data {String} tag: The tag that you can associate with the message [Optional]
880 @options data {String} type: Type of message. Possible values – marketing (default) & transactional. You can use marketing for sending marketing SMS, & for sending transactional SMS, use transactional type [Optional]
881 */
882 public function send_sms($data)
883 {
884 return $this->post("sms",$data);
885 }
886
887 /*
888 Create & Schedule your SMS campaigns.
889 @param {Array} data contains php array with key value pair.
890 @options data {String} name: Name of the SMS campaign [Mandatory]
891 @options data {String} sender: This allows you to customize the SMS sender. The number of characters is limited to 11 ( alphanumeric format ) [Optional]
892 @options data {String} content: Content of the message. The maximum characters used per SMS is 160, if used more than that, it will be counted as more than one SMS [Optional]
893 @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number defined here should belong to one of your contacts in Sendinblue account and should not be blacklisted [Optional]
894 @options data {Array} listid: These are the list ids to which the SMS campaign is sent [Mandatory: if scheduled_date is not empty]
895 @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS campaign [Optional]
896 @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
897 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
898 */
899 public function create_sms_campaign($data)
900 {
901 return $this->post("sms",$data);
902 }
903
904 /*
905 Update your SMS campaigns.
906 @param {Array} data contains php array with key value pair.
907 @options data {Integer} id: Id of the SMS campaign [Mandatory]
908 @options data {String} name: Name of the SMS campaign [Optional]
909 @options data {String} sender: This allows you to customize the SMS sender. The number of characters is limited to 11 ( alphanumeric format ) [Optional]
910 @options data {String} content: Content of the message. The maximum characters used per SMS is 160, if used more than that, it will be counted as more than one SMS [Optional]
911 @options data {String} bat: Mobile number with the country code to send test SMS. The mobile number defined here should belong to one of your contacts in Sendinblue account and should not be blacklisted [Optional]
912 @options data {Array} listid: hese are the list ids to which the SMS campaign is sent [Mandatory: if scheduled_date is not empty]
913 @options data {Array} exclude_list: These are the list ids which will be excluded from the SMS campaign [Optional]
914 @options data {String} scheduled_date: The day on which the SMS campaign is supposed to run [Optional]
915 @options data {Integer} send_now: Flag to send campaign now. Possible values = 0 (default) & 1. send_now = 0 means campaign can’t be send now, & send_now = 1 means campaign ready to send now [Optional]
916 */
917 public function update_sms_campaign($data)
918 {
919 $id = $data['id'];
920 unset($data['id']);
921 return $this->put("sms/".$id,$data);
922 }
923
924 /*
925 Send a Test SMS.
926 @param {Array} data contains php array with key value pair.
927 @options data {Integer} id: Id of the SMS campaign [Mandatory]
928 @options data {String} to: Mobile number with the country code to send test SMS. The mobile number defined here should belong to one of your contacts in Sendinblue account and should not be blacklisted [Mandatory]
929 */
930 public function send_bat_sms($data)
931 {
932 $id = $data['id'];
933 unset($data['id']);
934 return $this->get("sms/".$id,$data);
935 }
936 /*
937 * */
938 public function get_access_tokens()
939 {
940 return $this->get("account/token","");
941 }
942 public function delete_token($key)
943 {
944 return $this->post("account/deletetoken", json_encode(array("token"=>$key)));
945 }
946
947 /**
948 * Method is used to update the user info using web service in Sendinblue.
949 */
950 public function updateUser($data=array()) {
951 $data['key'] = $this->api_key;
952 $data['webaction'] = 'USERCREADIT';
953 //$data['timezone'] = date_default_timezone_get();
954 $result = json_decode($this->curlRequest($data),true);
955 return $result['result'];
956 }
957
958 /**
959 * Method is used to add the partner's name in Sendinblue.
960 * In this case its "WORDPRESS".
961 */
962 public function partnerWordpress() {
963 $data = array();
964 $data['key'] = $this->api_key;
965 $data['webaction'] = 'MAILIN-PARTNER';
966 $data['partner'] = 'WORDPRESS';
967 $this->curlRequest($data);
968 }
969 /**
970 * Get default config of user
971 */
972 public function getPluginConfig()
973 {
974 return $this->get("account/plugin_config", "");
975 }
976 /**
977 * CURL function to send request to the Sendinblue API server
978 */
979 public function curlRequest($data)
980 {
981 // prepare data for curl post
982 $ndata = '';
983 $data['source'] = 'Wordpress';
984 if (is_array($data))
985 foreach ($data as $key => $value)
986 $ndata .= $key.'='.urlencode($value).'&';
987 else
988 $ndata = $data;
989 $url = 'http://ws.mailin.fr/';
990
991 $args = array(
992 'method' => 'POST',
993 'sslverify' => false,
994 'headers' => array('Expect' => ''),
995 'body' => $ndata
996 );
997
998 $response = wp_remote_request($url, $args);
999 if( is_wp_error($response) ){
1000 $data = array(
1001 'code' => $response->get_error_message()
1002 );
1003 return $data;
1004 }
1005 $data = wp_remote_retrieve_body($response);
1006 return json_decode($data,true);
1007 }
1008 }
1009 ?>
1010