首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

OAuth::fetch

(PECL OAuth >= 0.99.1)

OAuth::fetch — Fetch an OAuth protected resource

Description

代码语言:javascript
复制
public mixed OAuth::fetch ( string $protected_resource_url [, array $extra_parameters [, string $http_method [, array $http_headers ]]] )

Fetch a resource.

Parameters

protected_resource_url

URL to the OAuth protected resource.

extra_parameters

Extra parameters to send with the request for the resource.

http_method

One of the OAUTH_HTTP_METHOD_* OAUTH constants, which includes GET, POST, PUT, HEAD, or DELETE.

HEAD (OAUTH_HTTP_METHOD_HEAD) can be useful for discovering information prior to the request (if OAuth credentials are in the Authorization header).

http_headers

HTTP client headers (such as User-Agent, Accept, etc.)

Return Values

Returns TRUE on success or FALSE on failure.

Changelog

Version

Description

1.0.0

Previously returned NULL on failure, instead of FALSE.

0.99.5

The http_method parameter was added

0.99.8

The http_headers parameter was added

Examples

Example #1 OAuth::fetch() example

代码语言:javascript
复制
<?php
try?{
????$oauth?=?new?OAuth("consumer_key","consumer_secret",OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
????$oauth->setToken("access_token","access_token_secret");

????$oauth->fetch("http://photos.example.net/photo?file=vacation.jpg");

????$response_info?=?$oauth->getLastResponseInfo();
????header("Content-Type:?{$response_info["content_type"]}");
????echo?$oauth->getLastResponse();
}?catch(OAuthException?$E)?{
????echo?"Exception?caught!\n";
????echo?"Response:?".?$E->lastResponse?.?"\n";
}
?>

See Also

  • OAuth::getLastResponse() - Get the last response
  • OAuth::getLastResponseInfo() - Get HTTP information about the last response
  • OAuth::setToken() - Sets the token and secret

← OAuth::enableSSLChecks

OAuth::generateSignature →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com