{
    "content": [
        {
            "type": "text",
            "text": "# Net::Twitter::Manual::MigratingToV1_1 (perldoc)\n\n## NAME\n\nNet::Twitter::Manual::MigratingToV11 - Migrating from Twitter API v1 to v1.1\n\n## SYNOPSIS\n\nuse Net::Twitter\nmy $nt = Net::Twitter->new(\ntraits              => [qw/API::RESTv11/],\nconsumerkey        => $consumerkey,\nconsumersecret     => $consumersecret,\naccesstoken        => $accesstoken,\naccesstokensecret => $accesstokensecret,\n);\n\n## DESCRIPTION\n\nNet::Twitter prior to version 4.0 used Twitter API version 1. Twitter API v1.1 introduced\nchanges that are not entirely backwards compatible, requiring some changes to calling code.\n\n## Sections\n\n- **NAME**\n- **VERSION**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FIRST** (1 subsections)\n- **EXCEPTIONS**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Net::Twitter::Manual::MigratingToV1_1",
        "section": "",
        "mode": "perldoc",
        "summary": "Net::Twitter::Manual::MigratingToV11 - Migrating from Twitter API v1 to v1.1",
        "synopsis": "use Net::Twitter\nmy $nt = Net::Twitter->new(\ntraits              => [qw/API::RESTv11/],\nconsumerkey        => $consumerkey,\nconsumersecret     => $consumersecret,\naccesstoken        => $accesstoken,\naccesstokensecret => $accesstokensecret,\n);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "VERSION",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 10,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "FIRST",
                "lines": 1,
                "subsections": [
                    {
                        "name": "Include the API::RESTv11 trait",
                        "lines": 3
                    }
                ]
            },
            {
                "name": "EXCEPTIONS",
                "lines": 104,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Net::Twitter::Manual::MigratingToV11 - Migrating from Twitter API v1 to v1.1\n",
                "subsections": []
            },
            "VERSION": {
                "content": "version 4.01043\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Net::Twitter\n\nmy $nt = Net::Twitter->new(\ntraits              => [qw/API::RESTv11/],\nconsumerkey        => $consumerkey,\nconsumersecret     => $consumersecret,\naccesstoken        => $accesstoken,\naccesstokensecret => $accesstokensecret,\n);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Net::Twitter prior to version 4.0 used Twitter API version 1. Twitter API v1.1 introduced\nchanges that are not entirely backwards compatible, requiring some changes to calling code.\n\nNet::Twitter attempts to provided backwards compatibility where possible. This document\ndescribes the changes required to your existing application code, using Net::Twitter, for use\nwith Twitter's API v1.1.\n",
                "subsections": []
            },
            "FIRST": {
                "content": "",
                "subsections": [
                    {
                        "name": "Include the API::RESTv11 trait",
                        "content": "Wherever you create a Net::Twitter object by calling \"new\", replace trait \"API::REST\" with\n\"API::RESTv11\". For most applications, that's all that is required.\n"
                    }
                ]
            },
            "EXCEPTIONS": {
                "content": "Trait RateLimit incompatible with API::RESTv11\nThe \"RateLimit\" trait is incompatible with Twitter API v1.1. Rate limiting is one of the\nmost extensive changes in v1.1. In v1 there were two hourly rate limits, one per IP address\nfor unauthenticated calls, and one per-user/application for authenticated calls. In v1.1,\nall calls must be authenticated, and each API endpoint (i.e., each method) has it's own rate\nlimit. Rather than hourly, the new rate limits operate on a 15 minute window.\n\nIf your code currently uses the \"RateLimit\" role, you'll need to write some custom code\nprovide equivalent functionality.\n\nratelimitstatus\nThe return value for \"ratelimitstatus\" is entirely different. See Twitter's API\nratelimitstatus <https://dev.twitter.com/docs/api/1.1/get/application/ratelimitstatus>\ndocumentation for details.\n\nblocking\nblockingids\nfriends\nfollowers\nWith API v1.1, these methods use cursor based paging. If you do not pass a \"cursor\"\nparameter, Twitter assumes \"cursor => -1\">. Existing code that expects an arrayref return\nvalue must be modified to expect a hashref and dereference the \"users\" slot:\n\n# With API v1\nmy $r = $nt->friends;\nmy @friends = @$r;\n\n# With API v1.1\nmy $r = $nt->friends;\nmy @friends = @{$r->{users}};\n\nsearch\nThe \"search\" method semantics and return value are substantially different between Twitter\nAPI v1 and v1.1. In v1, \"search\" was provided by the \"API::Search\" trait. In v1.1, \"search\"\nis included in the \"API::RESTv11\" trait.\n\nSo, first, drop \"API::Search\" from your calls to \"new\". The \"API::Search\" trait is\nincompatible with \"API::RESTv11\".\n\nIn v1, Twitter returned a hashref with several keys containing meta data. The actual array\nof results were contained in the \"results\" slot:\n\n# With Twitter API v1\nmy $nt = Net::Twitter->new(traits => [qw/API::REST API::Search/]);\n\nmy $r = $nt->search('perl hacker');\nfor my $status ( @{$r->{results} ) {\n# process each status...\n}\n\nIn v1.1, Twitter returns a hash with 2 slots: \"searchmetadata\" and \"statuses\".\n\n# With Twitter API v1.1\nmy $nt = Net::Twitter->new(traits => [qw/API::RESTv11/], %oauthcredentials);\n\nmy $r = $nt->search('perl hacker');\nfor my $status ( @{$r->{statuses} ) {\n# process each status...\n}\n\nPaging through search results works differently in v1.1. In v1, Twitter offered a \"page\"\nparameter:\n\n# With Twitter API v1\nfor ( my $page = 1; $page <= 10; ++$page ) {\nmy $r = $nt->search({ q => $query, page => $page, rpp => 100 });\nlast unless @{$r->{results}};\n\n# process a page of results...\n}\n\nIn v1.1, use \"maxid\" and \"count\" to get paged results:\n\n# With Twitter API v1.1\nfor ( my %args = ( q => $query, count => 100 ), my $n = 0; $n < 1000; ) {\nmy $r = $nt->search({ %args });\nlast unless @{$r->{statuses}};\n\n$args{maxid} = $r->{statuses}[-1]{id} - 1;\n$n += @{$r->{statuses}};\n\n# process a page of results...\n}\n\nDEPRECATED METHODS\nSome Twitter API v1 methods are not available in v1.1:\n\nfriendstimeline\nUse \"hometimeline\" instead.\n\nfriendshipexists\nrelationshipexists\nfollows\n\"friendshipexists\" and it's aliases are not supported in API v1.1. Use \"showfriendship\"\ninstead:\n\nmy $r = $nt->showrelationship({\nsourcescreenname => $usera,\ntargetscreenname => $userb,\n});\nif ( $r->{relationship}{source}{following} ) {\n# $usera follows $userb\n}\n",
                "subsections": []
            }
        }
    }
}