当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestCore::get_response_code方法代码示例

本文整理汇总了PHP中RequestCore::get_response_code方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestCore::get_response_code方法的具体用法?PHP RequestCore::get_response_code怎么用?PHP RequestCore::get_response_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestCore的用法示例。


在下文中一共展示了RequestCore::get_response_code方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sign_url_for_put

function sign_url_for_put($obj)
{
    global $bucket;
    global $object;
    $timeout = 3600;
    //通过content上传
    $options = NULL;
    $response = $obj->presign_url($bucket, $object, $timeout, "PUT", $options);
    SampleUtil::my_echo("签名的URL为:" . $response);
    $content = 'abcdefg';
    $request = new RequestCore($response);
    $request->set_method('PUT');
    $request->add_header('Content-Type', '');
    $request->add_header('Content-Length', strlen($content));
    $request->set_body($content);
    $request->send_request();
    $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
    if ($res->isOK()) {
        SampleUtil::my_echo("签名上传字符串成功");
    } else {
        SampleUtil::my_echo("签名上传字符串失败");
    }
    //通过file上传
    $file = __FILE__;
    if (!file_exists($file)) {
        throw new OSS_Exception($file . OSS_FILE_NOT_EXIST);
    }
    $options = array('Content-Type' => 'txt');
    $response = $obj->presign_url($bucket, $object, $timeout, "PUT", $options);
    SampleUtil::my_echo("签名的URL为:" . $response);
    $request = new RequestCore($response);
    $request->set_method('PUT');
    $request->add_header('Content-Type', 'txt');
    $request->set_read_file($file);
    $request->set_read_stream_size(filesize($file));
    $request->send_request();
    $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
    if ($res->isOK()) {
        SampleUtil::my_echo("签名上传文件成功");
    } else {
        SampleUtil::my_echo("签名上传字符串失败");
    }
}
开发者ID:codingoneapp,项目名称:codingone,代码行数:43,代码来源:signature_sample.php

示例2: getHttpResponse

 /**
  * @return array
  */
 protected function getHttpResponse($method, $url, $body, $headers)
 {
     $request = new RequestCore($url);
     foreach ($headers as $key => $value) {
         $request->add_header($key, $value);
     }
     $request->set_method($method);
     $request->set_useragent(USER_AGENT);
     if ($method == "POST") {
         $request->set_body($body);
     }
     $request->send_request();
     $response = array();
     $response[] = (int) $request->get_response_code();
     $response[] = $request->get_response_header();
     $response[] = $request->get_response_body();
     return $response;
 }
开发者ID:jesse108,项目名称:admin_base,代码行数:21,代码来源:Client.php

示例3: _baseControl

 /**
  * _baseControl
  *   
  * 用户关注:否
  * 
  * 网络交互方法
  * 
  * @access protected
  * @param array $opt 参数数组
  * @throws ChannelException 如果出错,则抛出异常,错误号为self::CHANNEL_SDK_SYS
  * 
  * @version 1.0.0.0
  */
 protected function _baseControl($opt)
 {
     $content = '';
     $resource = 'channel';
     if (isset($opt[self::CHANNEL_ID]) && !is_null($opt[self::CHANNEL_ID]) && !in_array($opt[self::METHOD], $this->_method_channel_in_body)) {
         $resource = $opt[self::CHANNEL_ID];
         unset($opt[self::CHANNEL_ID]);
     }
     $host = $opt[self::HOST];
     unset($opt[self::HOST]);
     $url = $host . '/rest/2.0/' . self::PRODUCT . '/';
     $url .= $resource;
     $http_method = 'POST';
     $opt[self::SIGN] = $this->_genSign($http_method, $url, $opt);
     foreach ($opt as $k => $v) {
         $k = urlencode($k);
         $v = urlencode($v);
         $content .= $k . '=' . $v . '&';
     }
     $content = substr($content, 0, strlen($content) - 1);
     $request = new RequestCore($url);
     $headers['Content-Type'] = 'application/x-www-form-urlencoded';
     $headers['User-Agent'] = 'Baidu Channel Service Phpsdk Client';
     foreach ($headers as $headerKey => $headerValue) {
         $headerValue = str_replace(array("\r", "\n"), '', $headerValue);
         if ($headerValue !== '') {
             $request->add_header($headerKey, $headerValue);
         }
     }
     $request->set_method($http_method);
     $request->set_body($content);
     if (is_array($this->_curlOpts)) {
         $request->set_curlopts($this->_curlOpts);
     }
     $request->send_request();
     return new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
 }
开发者ID:ycltpe,项目名称:sig,代码行数:50,代码来源:Channel.class.php

示例4: auth


//.........这里部分代码省略.........
                 $stats = fstat($options[self::OSS_FILE_UPLOAD]);
                 if ($stats && $stats[self::OSS_SIZE] >= 0) {
                     $length = $stats[self::OSS_SIZE] - (int) $options[self::OSS_SEEK_TO];
                 }
             }
             $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length);
             if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
             }
         } else {
             $request->set_read_file($options[self::OSS_FILE_UPLOAD]);
             $length = $request->read_stream_size;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) {
                 $length -= (int) $options[self::OSS_SEEK_TO];
             }
             $request->set_read_stream_size($length);
             if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $extension = explode('.', $options[self::OSS_FILE_UPLOAD]);
                 $ext = array_pop($extension);
                 $mime_type = MimeTypes::get_mimetype($ext);
                 $headers[self::OSS_CONTENT_TYPE] = $mime_type;
             }
         }
         $options[self::OSS_CONTENT_MD5] = '';
     }
     if (isset($options[self::OSS_SEEK_TO])) {
         $request->set_seek_position((int) $options[self::OSS_SEEK_TO]);
     }
     if (isset($options[self::OSS_FILE_DOWNLOAD])) {
         if (is_resource($options[self::OSS_FILE_DOWNLOAD])) {
             $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]);
         } else {
             $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]);
         }
     }
     if (isset($options[self::OSS_METHOD])) {
         $request->set_method($options[self::OSS_METHOD]);
         $string_to_sign .= $options[self::OSS_METHOD] . "\n";
     }
     if (isset($options[self::OSS_CONTENT])) {
         $request->set_body($options[self::OSS_CONTENT]);
         if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
             $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
         }
         $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
         $headers[self::OSS_CONTENT_MD5] = $this->hex_to_base64(md5($options[self::OSS_CONTENT]));
     }
     uksort($headers, 'strnatcasecmp');
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         if ($header_value !== '') {
             $request->add_header($header_key, $header_value);
         }
         if (strtolower($header_key) === 'content-md5' || strtolower($header_key) === 'content-type' || strtolower($header_key) === 'date' || isset($options['self::OSS_PREAUTH']) && (int) $options['self::OSS_PREAUTH'] > 0) {
             $string_to_sign .= $header_value . "\n";
         } elseif (substr(strtolower($header_key), 0, 6) === self::OSS_DEFAULT_PREFIX) {
             $string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n";
         }
     }
     $string_to_sign .= '/' . $options[self::OSS_BUCKET];
     $string_to_sign .= $this->enable_domain_style ? $options[self::OSS_BUCKET] != '' ? $options[self::OSS_OBJECT] == '/' ? '/' : '' : '' : '';
     $string_to_sign .= rawurldecode($signable_resource) . urldecode($signable_query_string);
     $msg .= "STRING TO SIGN:----------------------------------------------\n" . $string_to_sign . "\n";
     $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $this->access_key, true));
     $request->add_header('Authorization', 'OSS ' . $this->access_id . ':' . $signature);
     if (isset($options[self::OSS_PREAUTH]) && (int) $options[self::OSS_PREAUTH] > 0) {
         return $this->request_url . $conjunction . self::OSS_URL_ACCESS_KEY_ID . '=' . $this->access_id . '&' . self::OSS_URL_EXPIRES . '=' . $options[self::OSS_PREAUTH] . '&' . self::OSS_URL_SIGNATURE . '=' . rawurlencode($signature);
     } elseif (isset($options[self::OSS_PREAUTH])) {
         return $this->request_url;
     }
     if ($this->debug_mode) {
         $request->debug_mode = $this->debug_mode;
     }
     $msg .= "REQUEST HEADERS:----------------------------------------------\n" . serialize($request->request_headers) . "\n";
     $request->send_request();
     $response_header = $request->get_response_header();
     $response_header['x-oss-request-url'] = $this->request_url;
     $response_header['x-oss-redirects'] = $this->redirects;
     $response_header['x-oss-stringtosign'] = $string_to_sign;
     $response_header['x-oss-requestheaders'] = $request->request_headers;
     $msg .= "RESPONSE HEADERS:----------------------------------------------\n" . serialize($response_header) . "\n";
     $data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code());
     if ((int) $request->get_response_code() === 400 || (int) $request->get_response_code() === 500 || (int) $request->get_response_code() === 503) {
         if ($this->redirects <= $this->max_retries) {
             //设置休眠
             $delay = (int) (pow(4, $this->redirects) * 100000);
             usleep($delay);
             $this->redirects++;
             $data = $this->auth($options);
         }
     }
     $msg .= "RESPONSE DATA:----------------------------------------------\n" . serialize($data) . "\n";
     $msg .= date('Y-m-d H:i:s') . ":---LOG END---------------------------------------------------------------------------\n";
     //add log
     $this->log($msg);
     $this->redirects = 0;
     return $data;
 }
开发者ID:ijustyce,项目名称:zblogphp,代码行数:101,代码来源:sdk.class.php

示例5: auth


//.........这里部分代码省略.........
     $request->set_useragent($user_agent);
     // Streaming uploads
     if (isset($options[self::OSS_FILE_UPLOAD])) {
         if (is_resource($options[self::OSS_FILE_UPLOAD])) {
             $length = null;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO])) {
                 $stats = fstat($options[self::OSS_FILE_UPLOAD]);
                 if ($stats && $stats[self::OSS_SIZE] >= 0) {
                     $length = $stats[self::OSS_SIZE] - (int) $options[self::OSS_SEEK_TO];
                 }
             }
             $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length);
             if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
             }
         } else {
             $request->set_read_file($options[self::OSS_FILE_UPLOAD]);
             $length = $request->read_stream_size;
             if (isset($options[self::OSS_CONTENT_LENGTH])) {
                 $length = $options[self::OSS_CONTENT_LENGTH];
             } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) {
                 $length -= (int) $options[self::OSS_SEEK_TO];
             }
             $request->set_read_stream_size($length);
             if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
                 $mime_type = self::get_mime_type($options[self::OSS_FILE_UPLOAD]);
                 $headers[self::OSS_CONTENT_TYPE] = $mime_type;
             }
         }
     }
     if (isset($options[self::OSS_SEEK_TO])) {
         $request->set_seek_position((int) $options[self::OSS_SEEK_TO]);
     }
     if (isset($options[self::OSS_FILE_DOWNLOAD])) {
         if (is_resource($options[self::OSS_FILE_DOWNLOAD])) {
             $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]);
         } else {
             $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]);
         }
     }
     if (isset($options[self::OSS_METHOD])) {
         $request->set_method($options[self::OSS_METHOD]);
         $string_to_sign .= $options[self::OSS_METHOD] . "\n";
     }
     if (isset($options[self::OSS_CONTENT])) {
         $request->set_body($options[self::OSS_CONTENT]);
         if ($headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') {
             $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream';
         }
         $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]);
         $headers[self::OSS_CONTENT_MD5] = base64_encode(md5($options[self::OSS_CONTENT], true));
     }
     uksort($headers, 'strnatcasecmp');
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         if ($header_value !== '') {
             $request->add_header($header_key, $header_value);
         }
         if (strtolower($header_key) === 'content-md5' || strtolower($header_key) === 'content-type' || strtolower($header_key) === 'date' || isset($options['self::OSS_PREAUTH']) && (int) $options['self::OSS_PREAUTH'] > 0) {
             $string_to_sign .= $header_value . "\n";
         } elseif (substr(strtolower($header_key), 0, 6) === self::OSS_DEFAULT_PREFIX) {
             $string_to_sign .= strtolower($header_key) . ':' . $header_value . "\n";
         }
     }
     $string_to_sign .= '/' . $options[self::OSS_BUCKET];
     $string_to_sign .= $this->enable_domain_style ? $options[self::OSS_BUCKET] != '' ? $options[self::OSS_OBJECT] == '/' ? '/' : '' : '' : '';
     $string_to_sign .= rawurldecode($signable_resource) . urldecode($signable_query_string);
     $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $this->access_key, true));
     $request->add_header('Authorization', 'OSS ' . $this->access_id . ':' . $signature);
     if (isset($options[self::OSS_PREAUTH]) && (int) $options[self::OSS_PREAUTH] > 0) {
         $signed_url = $this->request_url . $conjunction . self::OSS_URL_ACCESS_KEY_ID . '=' . rawurlencode($this->access_id) . '&' . self::OSS_URL_EXPIRES . '=' . $options[self::OSS_PREAUTH] . '&' . self::OSS_URL_SIGNATURE . '=' . rawurlencode($signature);
         return $signed_url;
     } elseif (isset($options[self::OSS_PREAUTH])) {
         return $this->request_url;
     }
     if ($this->debug_mode) {
         $request->debug_mode = $this->debug_mode;
     }
     $request->send_request();
     $response_header = $request->get_response_header();
     $response_header['oss-request-url'] = $this->request_url;
     $response_header['oss-redirects'] = $this->redirects;
     $response_header['oss-stringtosign'] = $string_to_sign;
     $response_header['oss-requestheaders'] = $request->request_headers;
     $data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code());
     //retry if OSS Internal Error
     if ((int) $request->get_response_code() === 500) {
         if ($this->redirects <= $this->max_retries) {
             //设置休眠
             $delay = (int) (pow(4, $this->redirects) * 100000);
             usleep($delay);
             $this->redirects++;
             $data = $this->auth($options);
         }
     }
     $this->redirects = 0;
     return $data;
 }
开发者ID:codingoneapp,项目名称:codingone,代码行数:101,代码来源:sdk.class.php

示例6: invoke


//.........这里部分代码省略.........
                 $index = explode("->", $position);
                 $curIndexArg = $args;
                 $add = TRUE;
                 $curkey = "";
                 foreach ($index as $key1 => $value1) {
                     if (!isset($curIndexArg[$value1])) {
                         $add = FALSE;
                     } else {
                         $curIndexArg = $curIndexArg[$value1];
                         $curkey = $value1;
                     }
                 }
                 if (!empty($curIndexArg) && $add) {
                     $request->body = $curIndexArg;
                 }
             }
         }
     }
     //add ext headers
     //TODO
     //sign request
     $signer = NULL;
     if (isset($api["signer"])) {
         $signers = explode("->", $api["signer"]);
         foreach ($signers as $key => $value) {
             $signer = new $value();
             $log = $signer->sign($request, array("accessKey" => $this->accessKey, "secretKey" => $this->secretKey, "args" => $args));
             if (!empty($log)) {
                 $holder->msg .= $log . "\r\n";
             }
         }
     }
     if ($signer === NULL || !$signer instanceof QueryAuthSigner) {
         $url = $request->toUrl($this->endpoint);
         if ($location != NULL) {
             $url = $location;
         }
         $httpRequest = new RequestCore($url);
         if (KS3_API_DEBUG_MODE === TRUE) {
             $httpRequest->debug_mode = TRUE;
         }
         $httpRequest->set_method($request->method);
         foreach ($request->headers as $key => $value) {
             $httpRequest->add_header($key, $value);
         }
         $httpRequest->request_body = $request->body;
         if (isset($args["writeCallBack"])) {
             $httpRequest->register_streaming_write_callback($args["writeCallBack"]);
         }
         if (isset($args["readCallBack"])) {
             $httpRequest->register_streaming_read_callback($args["readCallBack"]);
         }
         $read_stream = $request->read_stream;
         $read_length = $request->getHeader(Headers::$ContentLength);
         $seek_position = $request->seek_position;
         if (isset($read_stream)) {
             $httpRequest->set_read_stream($read_stream, $read_length);
             $httpRequest->set_seek_position($seek_position);
             $httpRequest->remove_header(Headers::$ContentLength);
         }
         $write_stream = $request->write_stream;
         if (isset($write_stream)) {
             $httpRequest->set_write_stream($write_stream);
         }
         $holder->msg .= "request url->" . serialize($httpRequest->request_url) . "\r\n";
         $holder->msg .= "request headers->" . serialize($httpRequest->request_headers) . "\r\n";
         $holder->msg .= "request body->" . $httpRequest->request_body . "\r\n";
         $holder->msg .= "request read stream length->" . $read_length . "\r\n";
         $holder->msg .= "request read stream seek position->" . $seek_position . "\r\n";
         $httpRequest->send_request();
         //print_r($httpRequest);
         $body = $httpRequest->get_response_body();
         $data = new ResponseCore($httpRequest->get_response_header(), Utils::replaceNS2($body), $httpRequest->get_response_code());
         if ($data->status == 307) {
             $respHeaders = $httpRequest->get_response_header();
             $location = $respHeaders["location"];
             if (substr($location, 0, 4) == "http") {
                 $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
                 $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
                 $holder->msg .= "response body->" . $body . "\r\n";
                 $holder->msg .= "retry request to " . $location . "\r\n";
                 //array($args)详见invoke开头
                 return $this->invoke($method, array($args), $holder, $location);
             }
         }
         $holder->msg .= "response code->" . $httpRequest->get_response_code() . "\r\n";
         $holder->msg .= "response headers->" . serialize($httpRequest->get_response_header()) . "\r\n";
         $holder->msg .= "response body->" . $body . "\r\n";
         $handlers = explode("->", $api["handler"]);
         foreach ($handlers as $key => $value) {
             $handler = new $value();
             $data = $handler->handle($data);
         }
         return $data;
     } else {
         $url = $request->toUrl($this->endpoint);
         $holder->msg .= $url . "\r\n";
         return $url;
     }
 }
开发者ID:zengdongbao,项目名称:ks3-php,代码行数:101,代码来源:Ks3Client.class.php

示例7: _baseControl

 private function _baseControl($opt)
 {
     $content = '';
     $resource = 'queue';
     if (isset($opt[self::QUEUE_NAME]) && !is_null($opt[self::QUEUE_NAME])) {
         $resource = $opt[self::QUEUE_NAME];
         unset($opt[self::QUEUE_NAME]);
     } else {
         if (isset($opt[self::UID]) && !is_null($opt[self::UID])) {
             $resource = $opt[self::UID];
         }
     }
     $host = $opt[self::HOST];
     unset($opt[self::HOST]);
     foreach ($opt as $k => $v) {
         if (is_string($v)) {
             $v = urlencode($v);
         }
         $content .= $k . '=' . $v . '&';
     }
     $content = substr($content, 0, strlen($content) - 1);
     $url = 'http://' . $host . '/rest/2.0/' . self::PRODUCT . '/';
     $url .= $resource;
     $request = new RequestCore($url);
     $headers['Content-Type'] = 'application/x-www-form-urlencoded';
     $headers['User-Agent'] = 'Baidu Message Service Phpsdk Client';
     foreach ($headers as $headerKey => $headerValue) {
         $headerValue = str_replace(array("\r", "\n"), '', $headerValue);
         if ($headerValue !== '') {
             $request->add_header($headerKey, $headerValue);
         }
     }
     $request->set_method('POST');
     $request->set_body($content);
     if (is_array($this->_curlOpts)) {
         $request->set_curlOpts($this->_curlOpts);
     }
     $request->send_request();
     return new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code());
 }
开发者ID:dfc643,项目名称:tieba-sign-mod,代码行数:40,代码来源:bcms.php

示例8: authenticate

 /**
  * Authenticates a connection to cdnzz. Do not use directly unless implementing custom methods for
  * this class.
  *
  * @param array $options The options of the sdk request.
  * @return ResponseCore
  */
 public function authenticate($options = array())
 {
     if (!isset($options[self::CDNZZ_URL_USER])) {
         $options[self::CDNZZ_URL_USER] = $this->_username;
     }
     if (!isset($options[self::CDNZZ_URL_SIGNATURE])) {
         $options[self::CDNZZ_URL_SIGNATURE] = $this->_signature;
     }
     $scheme = $this->use_ssl ? 'https://' : 'http://';
     $hostname = $this->hostname;
     $headers = array(self::CDNZZ_HOST => $hostname, self::CDNZZ_CONTENT_TYPE => 'application/x-www-form-urlencoded', self::CDNZZ_DATE => gmdate('D, d M Y H:i:s \\G\\M\\T'));
     if (isset($options['url_path'])) {
         $path = $options['url_path'];
     }
     $request_url = $scheme . $hostname . $path;
     $request = new RequestCore($request_url);
     //$request->debug_mode=true;
     if (isset($options['api_method'])) {
         $request->set_method($options['api_method']);
     }
     $request_content = self::CDNZZ_URL_USER . '=' . $options[self::CDNZZ_URL_USER] . '&' . self::CDNZZ_URL_SIGNATURE . '=' . $options[self::CDNZZ_URL_SIGNATURE];
     if (isset($options['content'])) {
         foreach ($options['content'] as $content_key => $content_value) {
             $request_content .= '&' . $content_key . '=' . urlencode($content_value);
         }
     }
     $request->set_body($request_content);
     $headers[self::CDNZZ_CONTENT_LENGTH] = strlen($request_content);
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         $request->add_header($header_key, $header_value);
     }
     $request->send_request();
     $response_header = $request->get_response_header();
     $response_body = $request->get_response_body();
     $data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code());
     return $data;
 }
开发者ID:jefurry,项目名称:grid-sdk-php,代码行数:45,代码来源:cdnzzv1.sdk.class.php

示例9: request

 /**
  * Method: request()
  * 	Requests the data, parses it, and returns it. Requires RequestCore and SimpleXML.
  *
  * Parameters:
  * 	url - _string_ (Required) The web service URL to request.
  *
  * Returns:
  * 	ResponseCore object
  */
 public function request($url)
 {
     if (!$this->test_mode) {
         if (class_exists('RequestCore')) {
             $http = new RequestCore($url);
             $http->set_useragent(LASTFM_USERAGENT);
             $http->send_request();
             $response = new stdClass();
             $response->header = $http->get_response_header();
             $response->body = $this->parse_response($http->get_response_body());
             $response->status = $http->get_response_code();
             return $response;
         }
         throw new Exception('This class requires RequestCore. http://github.com/skyzyx/requestcore.');
     }
     return $url;
 }
开发者ID:MusicalAPP,项目名称:lastfm,代码行数:27,代码来源:lastfm.class.php

示例10: testPutObjectAclPresignedUrl

 public function testPutObjectAclPresignedUrl()
 {
     $this->testPutObjectPresignedUrl();
     $url = $this->client->generatePresignedUrl(array("Method" => "PUT", "Bucket" => $this->bucket, "Key" => $this->key, "Options" => array("Expires" => 60 * 10, "acl" => NULL), "Headers" => array("Content-Type" => "text/plain", "x-kss-acl" => "public-read")));
     $httpRequest = new RequestCore($url);
     $httpRequest->set_method("PUT");
     $httpRequest->add_header("Content-Type", "text/plain");
     $httpRequest->add_header("x-kss-acl", "public-read");
     $httpRequest->send_request();
     $body = $httpRequest->get_response_body();
     $this->assertEquals($httpRequest->get_response_code() . " body:" . $body, 200, "put object acl status code");
 }
开发者ID:leunico,项目名称:aliceBlog,代码行数:12,代码来源:Test.php

示例11: request

 /**
  * 发送请求
  */
 public function request($version, $action, $params)
 {
     $api_url = $this->getApiPath($version);
     $headers = array('Host' => self::OPEN_API_HOST . ':' . self::OPEN_API_PORT, 'Content-Type' => 'application/x-www-form-urlencoded', 'Date' => gmdate('D, d M Y H:i:s \\G\\M\\T'));
     $options = $this->_options;
     if (isset($options['user']) && isset($options['signature'])) {
         $api_user = $options['user'];
         $api_signature = $options['signature'];
     } else {
         $api_user = CDNZZ_USER;
         $api_signature = CDNZZ_SIGNATURE;
     }
     if (!is_array($params)) {
         $params = array();
     }
     if (isset($options['api_format'])) {
         $api_format = $options['api_format'];
     } else {
         $api_format = self::DEFAULT_API_FORMAT;
     }
     if (isset($options['method'])) {
         $method = $options['method'];
     } else {
         $method = self::OPEN_API_METHOD;
     }
     $params['user'] = $api_user;
     $params['signature'] = $api_signature;
     $body = http_build_query($params);
     $request_url = sprintf('%s%s.%s', $api_url, $action, $api_format);
     $request = new RequestCore($request_url);
     $request->set_method($method);
     $request->set_body($body);
     foreach ($headers as $header_key => $header_value) {
         $header_value = str_replace(array("\r", "\n"), '', $header_value);
         $request->add_header($header_key, $header_value);
     }
     $request->send_request();
     $response_header = $request->get_response_header();
     $response_body = $request->get_response_body();
     $response = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code());
     $result = (array) $response;
     if (!empty($result)) {
         $return_body = $result['body'];
         $return_arr = @json_decode($return_body, TRUE);
         if (is_array($return_arr) && !empty($return_arr)) {
             if (array_key_exists('errno', $return_arr) && array_key_exists('error', $return_arr) && array_key_exists('data', $return_arr)) {
                 $errno = $return_arr['errno'];
                 $error = $return_arr['error'];
                 $data = $return_arr['data'];
                 return array($errno, $error, $data);
             }
         }
     }
     return array(-1, 'network error, try again.', NULL);
 }
开发者ID:jefurry,项目名称:grid-sdk-php,代码行数:58,代码来源:cdnzz.sdk.class.php


注:本文中的RequestCore::get_response_code方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。