Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 22428 программистов и 1008 роботов. Сейчас ищут 710 программистов ...
Приступая к работе

OAuth::fetch - Fetch an OAuth protected resource

Вернуться к: OAuth

OAuth::fetch

(PECL OAuth >= 0.99.1)

OAuth::fetchFetch an OAuth protected resource

Описание

public mixed OAuth::fetch ( string $protected_resource_url [, array $extra_parameters [, string $http_method [, array $http_headers ]]] )

Fetch a resource.

Список параметров

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.)

Возвращаемые значения

Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

Список изменений

Версия Описание
1.0.0 Раньше при ошибке возвращался NULL вместо FALSE.
0.99.5 The http_method parameter was added
0.99.8 The http_headers parameter was added

Примеры

Пример #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";
}
?>

Смотрите также



Вернуться к: OAuth

© 2024 «PHP.RU — Сообщество PHP-Программистов»
Главная | Форум | Реклама на сайте | Контакты VIP Сувениры
Разработка компании ODware