Examples of the former:
An author friend's book was on sale at Amazon for like 99 cents. During the time it was on sale, she ran a contest on her blog. Basically, you told her on the blog that you bought her book and you were entered to win, but... the giveaway was tethered to the book's Amazon ranking (brilliant contest). If it hit the top... 100 (I think), she would give away a $10 gift card. If it stayed there for a week, she'd up it to $25. If it made the top 10, I think she was upping it to $50. I saw her tweet and facebook her standing a couple times--along with links to the contest. Anyone who was in the contest would be vested in those numbers as well, so it was less bragging and more sharing.
In other situations, I've seen authors hit the top 100 somewhere and post it with something like "OMG, you guys, "Book Title" just hit #87 on the B&N best seller list. To everyone who bought it or helped promote it, THANK YOU!" In this case, it's less bragging and more appreciative. (Also, the other author I mentioned? More often than not, she said thank you in her tweets/posts too.)
And that's the key. If you're going to throw that stuff out there (as anything more than a "Whatever bestseller" with the cover on your website), you need to make it about the reader. Be excited, but remember to be humble too.
As for how to do it wrong, I'm going to tear into someone who isn't an author, but is a recording artist whose work I love--Adam Lambert. I read an interview with him where he basically went off about fans who yell things to him like "I voted for you!" He comes across as believing that they didn't do anything, he made his career all on his own. Ummm... well, yes and no. Had people not voted for him on American Idol, he may not have stayed on the show very long and could have ended up back where he started--still on the road to stardom, but walking the long way instead of taking the shortcut provided by AI. Saying that is not to dismiss his talent at all. The guy is a brilliant vocalist (IMO) and deserves to be where he is, but he wouldn't be there yet if it weren't for people voting for him and buying his album and buying tickets to his performances.
Artists (of any sort) live and die by their fans. If no one cares about you or buys your work, it doesn't matter how brilliant you are.
So tweets and posts that just say "Woot! "Book Title" just hit #_____ on the bestseller list!" and nothing else? I get the excitement behind them, but as a reader, I ignore them because they don't mean anything to me. Connecting with fans even via adding a "Thank you" to those posts would make me more likely to sit up and take notice though because I'd see the author as one who cares about his or her fans. When people buy an artist's work, they are choosing to spend their hard earned money on what that person created. A little appreciation and humility goes a long way--and might even make someone new to their work take a second look.