本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
}