Hello, I am receiving the following error code:
Error Code: Duplicate Tweet or Twitter Refusal: [{u’message’: u’Status is a duplicate.’. u’code’: 187}]
I am working on the wifi_twit.py project posted at: https://github.com/DexterInd/GrovePi/blob/master/Projects/Sensor_Twitter_Feed/wifi_twit.py
Here is the code that I am working with in particular (with my twitter credentials omitted). You will notice a few modifications:
import twitter
import time
import grovepi
import math
# Connections
sound_sensor = 0 # port A0
light_sensor = 1 # port A1
temperature_sensor = 2 # port D2
led = 3 # port D3
intro_str = "The Batcave's"
# Connect to Twitter
api = twitter.Api(
consumer_key=' ',
consumer_secret=' ',
access_token_key=' ',
access_token_secret=' '
)
grovepi.pinMode(led,"OUTPUT")
grovepi.analogWrite(led,255) #turn led to max to show readiness
while True:
# Error handling in case of problems communicating with the GrovePi
try:
# Get value from light sensor
light_intensity = grovepi.analogRead(light_sensor)
# Give PWM output to LED
grovepi.analogWrite(led,light_intensity/4)
# Get sound level
sound_level = grovepi.analogRead(sound_sensor)
time.sleep(.5)
# Get value from temperature sensor
[t,h]=[0,0]
[t,h] = grovepi.dht(temperature_sensor,0)
t = ((t * 9) / 5.0) + 32
# Post a tweet
out_str ="%s Temp: %d F, Humidity: %d, Light: %d, Sound: %d" %(intro_str,t,h,light_intensity/10,sound_level)
print (out_str)
api.PostUpdate(out_str)
except IOError:
print("Error")
except KeyboardInterrupt:
exit()
except Exception as e:
print("Duplicate Tweet or Twitter Refusal: {}".format(e))
time.sleep(3600)
Any thoughts on what is causing this error? I would guess it is because the code is tweeting too often. I had previously posted about trying to lower the tweeting frequency, see here: Wifi_twit.py changing Celsius to Fahrenheit and changing frequency of tweet, and it was suggested that I add the <time.sleep(3600)> code to the last line, but that doesn’t seem to have solved the problem.