/** * * @param string $url 请求的地址 * @param array $post_data post数组 * @param int $timeout 超时设置 * @param sting $headers http头 * @param string $return http响应数据。可以是code, header,body,error */ public static function send($post_data = array(), $timeout = 5, $headers = array(), $return = 'body') { if (self::$open_debug) { self::$debug[] = self::$url; } $request = self::get_request($post_data); unset($post_data); $post_string = ''; if (!empty($request)) { if (self::$open_debug) { self::$debug[] = $request; } $post_string = http_build_query($request, '', '&'); unset($request); } $response = self::curl_send(self::$url, $post_string, empty($timeout) ? self::$timeout : $timeout, empty($headers) ? array() : $headers); unset($post_string, $timeout, $headers); if (self::$open_debug) { self::$debug[] = $response; } if (strpos($response['header'], 'session_id=')) { self::$session_id = substr(strstr($response['header'], 'session_id='), 11, 33); } self::reset(); return isset($response[$return]) ? $response[$return] : $response; }