芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentformpro/src/Integrations/ConstantContact/API.php
appKey = FF_CC_APP_KEY; } $this->access_token = $access_token; } // To get the authorization url for authorization code public function makeAuthorizationUrl() { return $url = 'https://api.constantcontact.com/mashery/account/'. $this->appKey ; } public function auth_test() { return $account = $this->make_request('account/info', [], 'GET'); } private function getApiUrl($resource) { $parameters = []; if ($resource =='contacts') { $actionName = 'ACTION_BY_OWNER'; $actionName = apply_filters_deprecated( 'ff_integration_constantcontact_action_by', [ $actionName ], FLUENTFORM_FRAMEWORK_UPGRADE, 'fluentform/integration_constantcontact_action_by', 'Use fluentform/integration_constantcontact_action_by instead of ff_integration_constantcontact_action_by.' ); $parameters['action_by'] = apply_filters('fluentform/integration_constantcontact_action_by', $actionName); } $parameters['api_key'] = $this->appKey; $paramString = http_build_query($parameters); return $this->api_url . $resource . '?' . $paramString; } public function make_request($resource, $data, $method = 'GET') { $requestApi = $this->getApiUrl($resource, $data); $args = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Bearer'. ' ' . $this->access_token ), 'body' => json_encode($data) ); if ($method == 'GET') { unset($args['body']); $response = wp_remote_get($requestApi, $args); } else if ($method == 'POST') { $args['headers']['action_by'] = 'ACTION_BY_OWNER'; $response = wp_remote_post($requestApi, $args); } else { return (new \WP_Error(423, 'Request method could not be found')); } /* If WP_Error, die. Otherwise, return decoded JSON. */ if (is_wp_error($response)) { return (new \WP_Error(423, $response->get_error_message())); } return json_decode($response['body'], true); } public function get_lists(){ return $this->make_request('lists', [], 'GET'); } public function subscribeToList($data){ return $this->make_request('contacts', $data, 'POST'); } }