|
NAMETwitter::API::Error - Twitter API exceptionVERSIONversion 1.0006SYNOPSISuse Try::Tiny; use Twitter::API; use Twitter::API::Util 'is_twitter_api_error'; my $client = Twitter::API->new(%options); try { my $r = $client->get('account/verify_credentials'); } catch { die $_ unless is_twitter_api_error($_); warn "Twitter says: ", $_->twitter_error_text; }; DESCRIPTIONTwitter::API dies, throwing a Twitter::API::Error exception when it receives an error. The error object contains information about the error so your code can decide how to respond to various error conditions.METHODShttp_requestReturns the HTTP::Request object used to make the Twitter API call.http_responseReturns the HTTP::Response object for the API call.twitter_errorReturns the inflated JSON error response from Twitter (if any).stack_traceReturns a Devel::StackTrace object encapsulating the call stack so you can discover, where, in your application the error occurred.stack_frameDelegates to "stack_trace->frame". See Devel::StackTrace for details.next_stack_framDelegates to "stack_trace->next_frame". See Devel::StackTrace for details.errorReturns a reasonable string representation of the exception. If Twitter returned error information in the form of a JSON body, it is mined for error text. Otherwise, the HTTP response status line is used. The stack frame is mined for the point in your application where the request initiated and appended to the message.When used in a string context, "error" is called to stringify exception. twitter_error_codeReturns the numeric error code returned by Twitter, or 0 if there is none. See <https://developer.twitter.com/en/docs/basics/response-codes> for details.is_token_errorReturns true if the error represents a problem with the access token or its Twitter account, rather than with the resource being accessed.Some Twitter error codes indicate a problem with authentication or the token/secret used to make the API call. For example, the account has been suspended or access to the application revoked by the user. Other error codes indicate a problem with the resource requested. For example, the target account no longer exists. is_token_error returns true for the following Twitter API errors:
For error 215, Twitter's API documentation says, "Typically sent with 1.1 responses with HTTP code 400. The method requires authentication but it was not presented or was wholly invalid." In practice, though, this error seems to be spurious, and often succeeds if retried, even with the same tokens. The Twitter API documentation describes error code 226, but in practice, they use code 326 instead, so we check for both. This error code means the account the tokens belong to has been locked for spam like activity and can't be used by the API until the user takes action to unlock their account. See Twitter's Error Codes & Responses <https://dev.twitter.com/overview/api/response-codes> documentation for more information. http_response_codeDelegates to "http_response->code". Returns the HTTP status code of the response.is_pemanent_errorReturns true for HTTP status codes representing an error and with values less than 500. Typically, retrying an API call with one of these statuses right away will simply result in the same error, again.is_temporary_errorReturns true or HTTP status codes of 500 or greater. Often, these errors indicate a transient condition. Retrying the API call right away may result in success. See the RetryOnError for automatically retrying temporary errors.AUTHORMarc Mims <marc@questright.com>COPYRIGHT AND LICENSEThis software is copyright (c) 2015-2021 by Marc Mims.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |