1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
if (!defined('ABSPATH')) exit; if (!class_exists('MCWPAPI')) : class MCWPAPI { public $settings;
public function __construct($settings) { $this->settings = $settings; }
public function pingbv($method, $body, $public = false) { if ($public) { $this->do_request($method, $body, $public); } else { $api_public_key = $this->settings->getOption('bvApiPublic'); if (!empty($api_public_key) && (strlen($api_public_key) >= 32)) { $this->do_request($method, $body, $api_public_key); } } }
public function do_request($method, $body, $pubkey) { $account = MCAccount::find($this->settings, $pubkey); if (isset($account)) { $url = $account->authenticatedUrl($method); $this->http_request($url, $body); } }
public function http_request($url, $body, $headers = array()) { $_body = array( 'method' => 'POST', 'timeout' => 15, 'body' => $body ); if (!empty($headers)) { $_body['headers'] = $headers; } return wp_remote_post($url, $_body); } } endif;
|