/** * Make an HTTP request * * @return API results */ function http($url, $method, $postfields = null, $multi = false) { if ($method == 'POST') { $multi = WP_Http::processHeaders($multi); $header = array("Content-Type" => "application/atom+xml"); $header = array_merge($header, $multi['headers']); } $params = array("method" => $method, "body" => $postfields, "headers" => $header); return class_http($url, $params); }
/** * Make an HTTP request * * @return string API results */ function http($url, $method, $postfields = null, $multi = false) { $params = array("method" => $method, "timeout" => $this->timeout, "user-agent" => $this->useragent, "sslverify" => $this->ssl_verifypeer, "body" => $postfields, "headers" => $multi ? array("Content-Type" => "multipart/form-data; boundary=" . OAuthUtil::$boundary, "Expect: ") : ''); return class_http($url, $params); }
function get_url_contents($url, $timeout = 30) { if (!close_curl()) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $content = curl_exec($ch); curl_close($ch); return $content; } else { $params = array(); if (@ini_get('allow_url_fopen')) { if (function_exists('file_get_contents')) { return file_get_contents($url); } if (function_exists('fopen')) { $params['http'] = 'streams'; } } elseif (function_exists('fsockopen')) { $params['http'] = 'fsockopen'; } else { return wp_die('没有可以完成请求的 HTTP 传输器,请查看<a href="' . MY_PLUGIN_URL . '/check.php" target="_blank">环境检查</a>'); } $params += array("method" => 'GET', "timeout" => $timeout, "sslverify" => false); return class_http($url, $params); } }
/** * Make an HTTP request * * @return string API results * @ignore */ function http($url, $method, $postfields = NULL, $headers = array()) { $params = array("method" => $method, "timeout" => $this->timeout, "user-agent" => $this->useragent, "sslverify" => $this->ssl_verifypeer, "body" => $postfields, "headers" => $headers); return class_http($url, $params); }
protected function makeRequest($url, $post = '', $timeout = 30) { $params = array("timeout" => $timeout, "user-agent" => $_SERVER[HTTP_USER_AGENT], "sslverify" => false); if ($post) { $params['method'] = 'POST'; $params['body'] = $post; } else { $params['method'] = 'GET'; } // return var_dump($url .= '?'.$post); return class_http($url, $params); //new }