芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentformpro/src/Integrations/SMSNotification/TwilioApi.php
authToken = $authToken; $this->accountSID = $accountSID; } public function default_options() { return array( 'api_key' => $this->apiKey ); } public function make_request($action, $options = array(), $method = 'GET') { $args = array( 'headers' => array( 'Authorization' => 'Basic ' . base64_encode($this->accountSID . ':' . $this->authToken), 'Content-Type' => 'application/json', ) ); /* Build request URL. */ $request_url = $this->apiUrl . $action; /* Execute request based on method. */ $response = ''; switch ($method) { case 'POST': $args['headers']['Content-Type'] = 'application/x-www-form-urlencoded'; //$request_url .= '?'.http_build_query($options); $args['body'] = $options; $response = wp_remote_post($request_url, $args); break; case 'GET': $response = wp_remote_get($request_url, $args); break; } /* If WP_Error, die. Otherwise, return decoded JSON. */ if (is_wp_error($response)) { return new \WP_Error($response->get_error_code(), $response->get_error_message()); } $code = wp_remote_retrieve_response_code($response); $body = json_decode(wp_remote_retrieve_body($response), true); if ($code >= 300) { $message = ArrayHelper::get($body, 'message'); return new \WP_Error($code, $message); } else { return $body; } } /** * Test the provided API credentials. * * @access public * @return bool */ public function auth_test() { return $this->make_request('Accounts.json', [], 'GET'); } public function sendSMS($accountId, $data) { $response = $this->make_request('Accounts/' . \rawurlencode($accountId) . '/Messages.json', $data, 'POST'); if (is_wp_error($response)) { return new \WP_Error($response->get_error_code(), $response->get_error_message()); } return $response; } }