You are here

function _twitter_request_failure in Twitter 6.2

Internal helper function to deal cleanly with various HTTP response codes.

6 calls to _twitter_request_failure()
twitter_fetch_account_info in ./twitter.inc
Fetch the full information for a Twitter.com account.
twitter_fetch_followers in ./twitter.inc
Fetch information about users following a given Twitter.com account.
twitter_fetch_friends in ./twitter.inc
Fetch information about Twitter.com accounts followed by a given user.
twitter_fetch_statuses in ./twitter.inc
Fetch the latest statuses for a Twitter.com account, regardless of privacy.
twitter_fetch_timeline in ./twitter.inc
Fetch the public timeline for a Twitter.com account.

... See full list

File

./twitter.inc, line 318
A wrapper API for the Twitter microblogging service.

Code

function _twitter_request_failure($results) {
  switch ($results->code) {
    case '304':

      // 304 Not Modified: there was no new data to return.
      return TRUE;
    case 400:

      // 400 Bad Request: your request is invalid, and we'll return an error message that tells you why. This is the status code returned if you've exceeded the rate limit
      watchdog('twitter', '400 Bad Request.');
      return TRUE;
    case 401:

      // 401 Not Authorized: either you need to provide authentication credentials, or the credentials provided aren't valid.
      watchdog('twitter', '401 Not Authorized.');
      return TRUE;
    case 403:

      // 403 Forbidden: we understand your request, but are refusing to fulfill it.  An accompanying error message should explain why.
      watchdog('twitter', '403 Forbidden.');
      return TRUE;
    case 404:

      // 404 Not Found: either you're requesting an invalid URI or the resource in question doesn't exist (ex: no such user).
      watchdog('twitter', '404 Not Found.');
      return TRUE;
    case 500:

      // 500 Internal Server Error: we did something wrong.  Please post to the group about it and the Twitter team will investigate.
      watchdog('twitter', '500 Internal Server Error.');
      return TRUE;
    case 502:

      // 502 Bad Gateway: returned if Twitter is down or being upgraded.
      watchdog('twitter', '502 Bad Gateway.');
      return TRUE;
    case 503:

      // 503 Service Unavailable: the Twitter servers are up, but are overloaded with requests.  Try again later.
      watchdog('twitter', '503 Service Unavailable.');
      return TRUE;
  }

  // 200 OK: everything went awesome.
  return FALSE;
}