0

I'm trying to use the twitter search API to pull tweets from Twitter, then store them in an S3 bucket using amazon Kinesis.

I'm trying to do this in python using the twitter search API, to store the tweets as JSON files on an EC2 Instance, then subsequently use the PutRecords API on AWS, to upload those JSON files to kinesis. This is the current code I am using for the twitter search API.

    #!/usr/bin/python

import json
import oauth2 as oauth

consumer_key = "XXXXXXXXXXXXXXXXX"
consumer_secret = "XXXXXXXXXXXXXXXX"

access_token = "XXXXXXXXXXXXXXXXXXX"
access_secret = "XXXXXXXXXXXXXXX"

consumer = oauth.Consumer(key=consumer_key, secret=consumer_secret)
access_token = oauth.Token(key=access_token, secret=access_secret)
client = oauth.Client(consumer, access_token)

timeline_endpoint = "https://api.twitter.com/1.1/search/tweets.json?l=&q=%27LoveIsland%27%2C%20OR%20%27LoveIsland2018%27%2C%20OR%20%27LoveIsland18%27&src=typd"

response, data = client.request(timeline_endpoint)

However, this is what twitter gives back:

b'{"errors":[{"code":32,"message":"Could not authenticate you."}]}'

Could anyone please offer any advice? I have added new tokens/keys and I am still getting the same error.

best, Ryan

Ryan
  • 101
  • 1
  • 6
  • Maybe https://stackoverflow.com/questions/30957373/how-should-i-use-consumer-object-in-oauth2-v-2-in-python-3-4 can help – shiftpsh Jul 30 '18 at 02:32
  • Thanks that helped me get past it! Sadly I now get stuck with the following error message. b'{"errors":[{"code":32,"message":"Could not authenticate you."}]}' – Ryan Jul 30 '18 at 12:35
  • Do you have access to the API? – shiftpsh Jul 31 '18 at 02:01
  • I have an app with read and write access on dev.twitter.com and I'm using the keys from that. I refreshed them after getting this error for the first time. So I have no idea why they aren't working. – Ryan Aug 01 '18 at 08:22

0 Answers0