(PECL OAuth >= 0.99.1)
OAuth::fetch — Obtiene un recurso protegido por OAuth
$protected_resource_url
,$extra_parameters
= ?,$http_method
= ?,$http_headers
= ?Obtiene un recurso.
protected_resource_url
URL del recurso OAuth protegio.
extra_parameters
Parámetros adicionales para enviar con la petición del recurso.
http_method
Una de las OAUTH_HTTP_METHOD_*
constantes OAUTH, 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
Encabezados cliente HTTP (como por ejemplo User-Agent, Accept, etc.)
Versión | Descripción |
---|---|
1.0.0 | Antes devolvía null en caso de falla, en lugar de false . |
0.99.5 | El parámetro http_method fue agregado |
0.99.8 | El parámetro http_headers fue agregado |
Ejemplo #1 Ejemplo de 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 "Excepción atrapada!\n";
echo "Respuesta: ". $E->lastResponse . "\n";
}
?>