芝麻web文件管理V1.00
编辑当前文件:/home/seolotod/critterchoice.com/wp-content/plugins/woozone/modules/bitly/init.php
the_plugin = $WooZone; $this->module_folder = $this->the_plugin->cfg['paths']['plugin_dir_url'] . 'modules/bitly/'; $this->module = $this->the_plugin->cfg['modules']['bitly']; $this->bitly_oauth_api = $this->the_plugin->bitly_oauth_api; if ( $this->the_plugin->is_admin !== true ) { } add_action( 'wp_ajax_WooZoneBitlyAuth', array( $this, 'auth_request' ) ); } /** * Singleton pattern * * @return WooZoneBitly Singleton instance */ static public function getInstance() { if (!self::$_instance) { self::$_instance = new self; } return self::$_instance; } public function auth_request() { $code = isset($_REQUEST['code']) ? (string) $_REQUEST['code'] : ''; if ( $code == "" ) { return true; } //:: code retrieved if (1) { $bitly_option = get_option( $this->the_plugin->alias . '_bitly', true ); $client_id = $bitly_option['client_id']; $client_secret = $bitly_option['client_secret']; $redirect_uri = $bitly_option['redirect_url']; $uri = $this->bitly_oauth_api . "oauth/access_token"; // POST to the bitly authentication endpoint $params = array(); $params['client_id'] = $client_id; $params['client_secret'] = $client_secret; $params['code'] = $code; $params['redirect_uri'] = $redirect_uri; $output = ""; $params_string = ""; foreach ($params as $key=>$value) { $params_string .= $key.'='.$value.'&'; } rtrim($params_string,'&'); //:: make request /*try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_POST, count($params)); curl_setopt($ch, CURLOPT_POSTFIELDS, $params_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); } catch (Exception $e) { if (isset($e->faultcode)) { // error occured! $__msg = $e->faultcode . ' : ' . (isset($e->faultstring) ? $e->faultstring : $e->getMessage()); var_dump('
', $__msg , '
'); echo __FILE__ . ":" . __LINE__; die . PHP_EOL; } }*/ $input_params = array( 'header' => true, 'post' => count($params), 'postfields' => $params_string, ); $output_params = array( 'parse_headers' => true, 'resp_is_json' => true, 'resp_add_http_code' => true, ); $output = $this->the_plugin->curl( $uri, $input_params, $output_params, true ); //var_dump('
', $output , '
'); echo __FILE__ . ":" . __LINE__;die . PHP_EOL; //:: end make request if ( $output['status'] === 'invalid' ) { $msg = sprintf( __('curl error; http code: %s; details: %s', 'psp'), $output['http_code'], $output['data'] ); var_dump('
', $msg , '
'); echo __FILE__ . ":" . __LINE__; die . PHP_EOL; } $output = $output['data']; parse_str( $output, $parseResult ); //:: error occured trying to get access token $access_token = isset($parseResult['access_token']) ? $parseResult['access_token'] : ''; if( '' == $access_token ) { $output = json_decode( $output, true ); if ( ! $output ) { var_dump('
', $output , '
'); echo __FILE__ . ":" . __LINE__; die . PHP_EOL; } else { $status_txt = isset($output['status_txt']) ? $output['status_txt'] : ''; ?>
Invalid response from Bitly Auth service:
the_plugin->alias . '_bitly_access_token', $access_token ); update_option( $this->the_plugin->alias . '_bitly_login', $login ); ?>
Congratulations!