First of all, here is my basic code:
<div id="example-ontweet"></div>
<script type="text/javascript">
twttr.anywhere(function (T) {
T("#example-ontweet").tweetBox({
onTweet : function(plaintext, html) {
alert(plaintext);
alert(html);
}
});
});
</script>
When I send I submit a tweet, it works fine like it should. When I try to submit a duplicate tweet, it doesn't allow it, and the loading spinner just spins with no error message--also default behavior. When I look in the firebug console upon duplicate tweet submit, I see:
POST https://api.twitter.com/1/statuses/update.json 403 forbidden
and under the Response console tab in there is this info:
{"error":"Status is a duplicate.","request":"\/1\/statuses\/update.json"}
All I want to do is alert that response message on fail--either the whole object, or preferably just the "error." I tried:
me.tweetBox.$button.click(function(){
$.getJSON('https://api.twitter.com/1/statuses/update.json', function(data) {
alert(JSON.stringify(data));
});
});
Both inside of a settimeout function and not, and it looked like it was going to work, but it spit this out below into the console when it tried:
GET https://api.twitter.com/1/statuses/update.json 401 Unauthorized
Any ideas of how to pull that error message into an alert? It seems like it should be so simple, but I'm banging my head against the wall. Thanks