What could be this Error?
Could not post Tweet. Error: 403 Reason: Status is a duplicate.
actually thi开发者_如何学运维s is a edited message .
i get error code as 403
and Reason as Status is a duplicate
.
Twitter checks messages if they are duplicates of the previous and does not accept them a second time.
So for testing you need to generate new messages (=content) each time.
This is documented somewhere at Twitter, but you can also read about on other sites.
The status is a duplicate, probably running your script twice without changing the status message.
Delete your last status update via Twitter web and run the script again. Or include date('r') or md5(mt_rand()) with your status message to generate a different one each time the script is run.
I also had encountered the same error. what the twitter site says is that they check the messages tweeted and discard (refuse) them if they are same. Discussion here says to use different texts each time you make a tweet. Else use a different account for tweeting.
import time, os, random, hashlib, datetime
gettime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
random_data = os.urandom(128)
hash = hashlib.md5(gettime).hexdigest()[:8]
twitterpost = "foo bar %s" % hash
api.update_status(status=twitterpost)
精彩评论