OAuth
PHP Manual

OAuth::fetch

(PECL OAuth >= 0.99.1)

OAuth::fetchFetch an OAuth protected resource

Beschreibung

public bool OAuth::fetch ( string $protected_resource_url [, array &$extra_parameters [, int &$http_method ]] )

Fetch a resource.

Parameter-Liste

protected_resource_url

URL to the OAuth protected resource.

extra_parameters

Extra parameters to send with the request for the resource.

http_method

http_method can be one of the following:

OAUTH_HTTP_METHOD_GET
Set the request method to GET.
OAUTH_HTTP_METHOD_POST
Set the request method to POST.
OAUTH_HTTP_METHOD_PUT
Set the request method to PUT.
OAUTH_HTTP_METHOD_HEAD
Set the request method to HEAD, this can be useful for discovering information prior to the request (if OAuth credentials are in the Authorization header).

Rückgabewerte

Gibt bei Erfolg TRUE zurück, im Fehlerfall FALSE.

Changelog

Version Beschreibung
CVS / 0.99.5 Added an additional parameter to set the HTTP method for the request.

Beispiele

Beispiel #1 OAuth::fetch() example

<?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";
}
?>

Siehe auch


OAuth
PHP Manual