Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the 'map' option in GET statuses/lookup #756

Closed
davebell opened this issue Feb 2, 2016 · 2 comments
Closed

Support for the 'map' option in GET statuses/lookup #756

davebell opened this issue Feb 2, 2016 · 2 comments

Comments

@davebell
Copy link

davebell commented Feb 2, 2016

If you attempt to use the map: true option for the Twitter::REST::Tweets#statuses REST API call (see https://dev.twitter.com/rest/reference/get/statuses/lookup), you'll get an exception.

=> client = Twitter::REST::Client.new { |config| ... }
=> client.statuses(19, 20, 432656548536401920, map: true)`
=> TypeError: no implicit conversion of Symbol into Integer from /gems/twitter-5.16.0/lib/twitter/identity.rb:16:in 'fetch'

This appears to be because of the different response formats being returned by the Twitter endpoint for map: true vs map: false (the default).

With map: false you get an array with hash elements for any tweet that exists for the ids passed.

[
   {
      "created_at":"Tue Mar 21 20:50:14 +0000 2006",
      "id":20,
      "id_str":"20",
      "text":"just setting up my twttr",
      ...
   },
   {
      "created_at":"Sun Feb 09 23:25:34 +0000 2014",
      "id":432656548536401920,
      "id_str":"432656548536401920",
      "text":"POST statuses\/update. Great way to start. https:\/\/t.co\/9S8YO69xzf (disclaimer, this was not posted via the API).",
      ...
   }
]

But with map: true you get a hash with a root key of id and a value containing a hash which maps each tweet id passed (whether it exists or not) to the tweet's attributes. For example, passing ids 19, 20, 21, you get:

{
   "id":{
      "19":null,
      "20":{
         "created_at":"Tue Mar 21 20:50:14 +0000 2006",
         "id":20,
         "id_str":"20",
         "text":"just setting up my twttr",
         ...
      },
      "21":{
         "created_at":"Tue Mar 21 20:51:43 +0000 2006",
         "id":21,
         "id_str":"21",
         "text":"just setting up my twttr",
         ...
      }
   }
}
@stve
Copy link
Collaborator

stve commented Mar 15, 2016

Hi @davebell, is there a use case for which you'd want to use the map param? I understand that it may be useful to know which tweets exist and which do not, but apart from that I can't quite figure out what else would be different.

@AbigailMcP
Copy link

Hi @stve - I've recently come across this too! Given that it's included in the Twitter API, it would be really useful to have the support for the map: true option. Use case is just what you identified - quickly and easily checking for deleted tweets.

@sferik sferik closed this as completed Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants