(PECL OAuth >= 0.99.1)
OAuth::fetch — Lit une ressource protégée par OAuth
$protected_resource_url,$extra_parameters = ?,$http_method = ?,$http_headers = ?Lit une ressource protégée par OAuth.
protected_resource_urlURL de la ressource protégées par OAuth.
extra_parametersParamètres supplémentaires à envoyer avec la requête, à la ressource.
http_method
Une des constantes OAUTH constants
OAUTH_HTTP_METHOD_*, incluant
GET, POST, PUT, HEAD, ou DELETE.
HEAD (OAUTH_HTTP_METHOD_HEAD) peut être utile
pour découvrir des informations avant la demande (si les autorisations
OAuth sont dans l'en-tête Authorization header).
http_headers
Les entêtes client HTTP (tels que User-Agent,
Accept, etc.)
| Version | Description |
|---|---|
| PECL oauth 1.0.0 |
Avant cette version, null était retourné au lieu de false.
|
| PECL oauth 0.99.5 |
Ajout du paramètre http_method
|
| PECL oauth 0.99.8 |
Ajout du paramètre http_headers
|
Exemple #1 Exemple avec OAuth::fetch()
<?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";
}
?>