PHP 8.5.0 Alpha 1 available for testing

Voting

: five plus zero?
(Example: nine)

The Note You're Voting On

chris dot barr at ntlworld dot com
12 years ago
The fetch() method will throw an OAuthException if the returned http status code is in the 4xx or 5xx range:

<?php
// Querying Twitter with bad login details
try {
$oauth->fetch('https://api.twitter.com/1.1/favorites/list.json');
}
catch(
Exception $e) {
echo
$e->getCode(); // 401
// Message generated by OAuth class
echo $e->getMessage(); // Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
// Message returned from Twitter
echo $e->lastResponse; // {"errors":[{"message":"Could not authenticate you","code":32}]}
}

<< Back to user notes page

To Top