templates
1 year ago
SendinblueAccount.php
1 year ago
SendinblueApiClient.php
4 months ago
function.wp_mail.php
8 years ago
http-build-url.php
1 year ago
index.php
8 years ago
mailin.php
3 years ago
push-admin.php
5 months ago
push-amp.php
1 year ago
push-api.php
5 months ago
push-httpclient.php
1 year ago
push-public.php
1 year ago
push-settings.php
5 months ago
push-utils.php
5 months ago
push-woocommerce.php
11 months ago
sendinblue.php
3 years ago
sib-api-manager.php
1 year ago
sib-form-preview.php
2 years ago
sib-sms-code.php
5 months ago
table-forms.php
1 year ago
mailin.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Sendinblue REST client |
| 5 | */ |
| 6 | |
| 7 | class Mailin |
| 8 | { |
| 9 | public $api_key; |
| 10 | public $base_url; |
| 11 | public function __construct($base_url,$api_key) |
| 12 | { |
| 13 | if(!function_exists('curl_init')) |
| 14 | { |
| 15 | throw new Exception('Mailin requires CURL module'); |
| 16 | } |
| 17 | $this->base_url = $base_url; |
| 18 | $this->api_key = $api_key; |
| 19 | } |
| 20 | /** |
| 21 | * Do CURL request with authorization |
| 22 | */ |
| 23 | private function do_request($resource,$method,$input) |
| 24 | { |
| 25 | $called_url = $this->base_url."/".$resource; |
| 26 | $ssl_verify = true; |
| 27 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
| 28 | // Windows only over-ride |
| 29 | $ssl_verify = false; |
| 30 | } |
| 31 | |
| 32 | $args = array( |
| 33 | 'method' => $method, |
| 34 | 'sslverify' => $ssl_verify, |
| 35 | 'headers' => array( |
| 36 | 'api-key' => $this->api_key, |
| 37 | 'Content-Type'=> 'application/json', |
| 38 | 'User-Agent' => 'sendinblue_plugins/wordpress', |
| 39 | ), |
| 40 | ); |
| 41 | $args['body'] = $input; |
| 42 | |
| 43 | $response = wp_remote_request($called_url, $args); |
| 44 | $data = wp_remote_retrieve_body($response); |
| 45 | |
| 46 | return json_decode($data,true); |
| 47 | } |
| 48 | public function post($resource,$input) |
| 49 | { |
| 50 | return $this->do_request($resource,"POST",json_encode($input)); |
| 51 | } |
| 52 | } |
| 53 | ?> |
| 54 |