(PECL OAuth >= 0.99.1)
OAuth::fetch — Lee un recurso protegido por OAuth
$protected_resource_url
,$extra_parameters
= ?,$http_method
= ?,$http_headers
= ?Lee un recurso protegido por OAuth.
protected_resource_url
URL del recurso protegido por OAuth.
extra_parameters
Argumentos adicionales a enviar con la petición, al recurso.
http_method
Una de las constantes OAUTH constants
OAUTH_HTTP_METHOD_*
, incluyendo
GET, POST, PUT, HEAD, o DELETE.
HEAD (OAUTH_HTTP_METHOD_HEAD
) puede ser útil
para descubrir información antes de la petición (si las autorizaciones
OAuth están en el encabezado Authorization
).
http_headers
Los encabezados HTTP del cliente (tales como User-Agent
,
Accept
, etc.)
Versión | Descripción |
---|---|
PECL oauth 1.0.0 |
Antes devolvía null en caso de falla, en lugar de false .
|
PECL oauth 0.99.5 |
Se añadió el argumento http_method
|
PECL oauth 0.99.8 |
Se añadió el argumento http_headers
|
Ejemplo #1 Ejemplo con 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";
}
?>