GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Twitter::API::Error(3) User Contributed Perl Documentation Twitter::API::Error(3)

Twitter::API::Error - Twitter API exception

version 1.0006

    use 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;
    };

Twitter::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.

Returns the HTTP::Request object used to make the Twitter API call.

Returns the HTTP::Response object for the API call.

Returns the inflated JSON error response from Twitter (if any).

Returns a Devel::StackTrace object encapsulating the call stack so you can discover, where, in your application the error occurred.

Delegates to "stack_trace->frame". See Devel::StackTrace for details.

Delegates to "stack_trace->next_frame". See Devel::StackTrace for details.

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

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

Returns 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:

  • 32: Could not authenticate you
  • 64: Your account is suspended and is not permitted to access this feature
  • 88: Rate limit exceeded
  • 89: Invalid or expired token
  • 99: Unable to verify your credentials.
  • 135: Could not authenticate you
  • 136: You have been blocked from viewing this user's profile.
  • 215: Bad authentication data
  • 226: This request looks like it might be automated. To protect our users from spam and other malicious activity, we canXt complete this action right now.
  • 326: To protect our users from spamX

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.

Delegates to "http_response->code". Returns the HTTP status code of the response.

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

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

Marc Mims <marc@questright.com>

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

2021-04-01 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.