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


PHP OAuth::getLastResponseHeaders方法代码示例

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


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

示例1: getResponse

 /**
  * @return Response
  */
 protected function getResponse()
 {
     $responseHeaders = $this->oAuthClient->getLastResponseHeaders();
     $response = Response::createFromRaw($responseHeaders);
     $response->appendContent($this->oAuthClient->getLastResponse());
     return $response;
 }
开发者ID:lightwerk,项目名称:surfcaptain,代码行数:10,代码来源:OAuthRequest.php

示例2: fetch_tarball_via_oauth

 protected static function fetch_tarball_via_oauth($key, $secret, $uri)
 {
     try {
         $oauth = new OAuth($key, $secret);
         $oauth->fetch($uri);
         WP_CLI::debug($oauth->getLastResponseHeaders());
         $headers = http_parse_headers($oauth->getLastResponseHeaders());
         $mime_type = self::parse_content_type_header($headers['Content-Type']);
         $content_disposition = self::parse_content_disposition_header($headers['Content-Disposition']);
         $filename = empty($content_disposition['filename']) ? $filename = tmpfile() : sys_get_temp_dir() . DIRECTORY_SEPARATOR . $content_disposition['filename'];
         file_put_contents($filename, $oauth->getLastResponse());
         return $filename;
     } catch (OAuthException $e) {
         WP_CLI::error_multi_line($e->getMessage(), true);
     }
     WP_CLI::error('Unknown error', true);
 }
开发者ID:nickbreen,项目名称:docker-wp-setup,代码行数:17,代码来源:SCM_Command.php

示例3: fetchJson

 /**
  * fetches JSON request on F1, parses and returns response
  * @param string $url
  * @param string|array $data
  * @param const $method
  * @return void
  */
 public function fetchJson($url, $data = null, $method = OAUTH_HTTP_METHOD_GET)
 {
     try {
         $o = new OAuth($this->settings->key, $this->settings->secret, OAUTH_SIG_METHOD_HMACSHA1);
         $o->setToken($this->accessToken->oauth_token, $this->accessToken->oauth_token_secret);
         $headers = array('Content-Type' => 'application/json');
         if ($o->fetch($url, $data, $method, $headers)) {
             if ($this->settings->debug) {
                 return array('headers' => self::http_parse_headers($o->getLastResponseHeaders()), 'response' => json_decode($o->getLastResponse(), true));
             }
             return json_decode($o->getLastResponse(), true);
         }
     } catch (OAuthException $e) {
         $this->error = array('method' => $method, 'url' => $url, 'response' => self::http_parse_headers($o->getLastResponseHeaders()));
         return $this->error;
     }
 }
开发者ID:SerdarSanri,项目名称:laravel-fellowshipone,代码行数:24,代码来源:FellowshipOne.php

示例4: GetOAuthResponseHeaders

 /**
  * Returns the response headers and response code from a called OAuth object
  *
  * @param OAuth $oauth A called OAuth object
  * @return array elements are 0: HTTP response code; 1: response content, 2: HTTP response headers
  */
 private function GetOAuthResponseHeaders($oauth)
 {
     $response_code = NULL;
     $response_xml = NULL;
     $response_headers = array();
     try {
         $response_xml = $oauth->getLastResponse();
         $response_headers = array();
         $response_headers_raw = $oauth->getLastResponseHeaders();
         $response_headers_rows = explode("\r\n", $response_headers_raw);
         foreach ($response_headers_rows as $header) {
             $keyval = explode(":", $header);
             if (2 == count($keyval)) {
                 $response_headers[$keyval[0]] = trim($keyval[1]);
             }
             if (FALSE !== strpos($header, 'HTTP')) {
                 list(, $response_code, ) = explode(' ', $header);
             }
         }
         // Decompress, if applicable
         if ('QBO' == $this->context->serviceType || 'QBD' == $this->context->serviceType) {
             // Even if accept-encoding is set to deflate, server never (as far as we know) actually chooses
             // to respond with Content-Encoding: deflate.  Thus, the inspection of 'Content-Encoding' response
             // header rather than assuming that server will respond with encoding specified by accept-encoding
             if ($this->ResponseCompressor && $response_headers && array_key_exists('Content-Encoding', $response_headers)) {
                 $response_xml = $this->ResponseCompressor->Decompress($response_xml, $response_headers);
             }
         }
     } catch (Exception $e) {
     }
     return array($response_code, $response_xml, $response_headers);
 }
开发者ID:elliotchance,项目名称:intuit-quickbooks,代码行数:38,代码来源:SyncRestHandler.php

示例5: obtainCredentialsBasedAccessToken

 /**
  * obtain credentials based access token from API
  * @param string $username
  * @param string $password
  * @param boolean $returnHeaders=false
  * @return array
  */
 protected function obtainCredentialsBasedAccessToken($username, $password, $returnHeaders = false)
 {
     try {
         $message = urlencode(base64_encode("{$username} {$password}"));
         $url = $this->settings->baseUrl . self::$paths['portalUser']['accessToken'] . "?ec={$message}";
         $o = new OAuth($this->settings->key, $this->settings->secret, OAUTH_SIG_METHOD_HMACSHA1);
         $token = $o->getAccessToken($url);
         if ($returnHeaders) {
             $token['headers'] = self::http_parse_headers($o->getLastResponseHeaders());
         }
         return (object) $token;
     } catch (OAuthException $e) {
         $this->error = array('error' => true, 'code' => $e->getCode(), 'response' => $e->lastResponse, 'url' => $url);
         return false;
     }
 }
开发者ID:Renddslow,项目名称:Fellowship-One-API-Helper,代码行数:23,代码来源:FellowshipOne.php


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