public static function putCache($key, $cached, Tuitter_Http_Response $res) { if ($cache = self::$_cache) { $sts = $res->getStatus(); if ($sts == 304) { return $cached; } else { if ($sts == 200) { $cacheKey = $key . '.cache'; $cache->put($cacheKey, $res->getResponse()); } } } return $res; }
protected function _getErrMsgByHttp(Tuitter_Http_Response $res) { $sts = $res->getStatus(); $msg = "Twitter returned HTTP code '{$sts}'. "; switch ($sts) { case 400: break; case 401: $msg .= 'Authentication credentials were missing or incorrect.'; break; case 403: $msg .= 'The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits.'; break; case 404: $msg .= 'The URI requested is invalid or the resource requested, such as a user, does not exists.'; break; case 406: $msg .= 'Returned by the Search API when an invalid format is specified in the request.'; break; case 500: $msg .= 'Something is broken. Please post to the group so the Twitter team can investigate.'; break; case 502: $msg .= 'Twitter is down or being upgraded.'; break; case 503: $msg .= 'The Twitter servers are up, but overloaded with requests. Try again later. The search and trend methods use this to indicate when you are being rate limited.'; break; default: $msg .= 'Unexpected error has occurred.'; } $hash = new Tuitter_Hash($this, $res->getBody()); if ($hash->error) { $msg .= ' The error message is "' . html_entity_decode($hash->error, ENT_QUOTES, 'UTF-8') . '".'; } return $msg; }