Getting invalid Tweet id and id_str


#1

I am using Ruby’s Twitter Gem (https://github.com/sferik/twitter) to interact with Rest API.

For some people, when I am posting a tweet through API, getting wrong Tweet id.
Both my Tweet id and id_str are same, but when I go to the profile, its showing a tweet with different id.

For example for when I posted to @PebbleInWaters, I got tweet id 829287112583286784 in the response but the actual tweet id is 829287114386894848.

Please help me to solve this issue.


#2

Are you using any Javascript in your code, or only Ruby? This sounds like a classic large integer issue.

The difference between id and id_str is documented here.


#3

I am using only Ruby… And read about classic large integer issue, but my id and id_str are same… Both are wrong… And its happening only for certain people only… Is this something related to privacy settings, @andypiper???


#4

I don’t see how this can relate to privacy settings. I cannot retrieve either of those Tweet IDs, however (that may be related to privacy settings). Can you provide an example code snippet that demonstrates the issue?


#5
@client = Twitter::REST::Client.new do |config|
  config.consumer_key        = ENV['TWITTER_CONSUMER_KEY']
  config.consumer_secret     = ENV['TWITTER_CONSUMER_KEY_SECRET']
  config.access_token        = token
  config.access_token_secret = token_secret
end

post_result = @client.update_with_media(content, image_file)
post_permalink = post_result.id
post_result = post_result.to_json

a part of post_result is like this

{"created_at":"Wed Feb 08 11:13:49 +0000 2017","id":829287112583286784,"id_str":"829287112583286784","text":"You must agree that the Classic Coffee without Chicory tastes thousands times better #ClassicCoffeeBrews https://t.co/fgORp5QDAy"}

Whem I am trying to access that tweet https://twitter.com/PebbleInWaters/status/829287112583286784 am getting error.

But when I went to his profile and understood the tweet id is 829287114386894848
See the post https://twitter.com/PebbleInWaters/status/829287114386894848

It’s happening for some 5 or 6 people only. That’s why I asked it’s related to any privacy settings. If u notice, the link in the content is also changed. What I got in response is https://t.co/fgORp5QDAy, but in the actual tweet its showing https://t.co/gNAw5hZpog

Please have a look @andypiper