YOU were the one who talked shiiiiiit about A behind her back. And you were stupid enough to put it in writing so that O could blast out the proof to everyone, to boot.
Lesson learned - gossip and smack-talk will always come back around to bite you in the butt. ALWAYS. And nothing that's said online or in a text or a Snapchat is EVER gone for good - once it's out there, it's out there, and you lose control over it.
If you don't want a person knowing that you said bad things about them, then DON'T SAY BAD THINGS ABOUT THEM.
You aren't a better person than O simply because you said the shiiiiit about A behind her back. If anything, you're worse because you're a sneak and a coward.
That being said, dump O as a friend if she's going to throw you under the bus like that. And take a long look in the mirror to ask yourself why you were so eager to talk shiiiiit on a supposedly good friend like A behind her back. Again, you're no better than O. She's not a good person for throwing you under the bus, but YOU were the one who said the shiiiiittty stuff about A in the first place. So you're BOTH crappy friends.
Sounds like you're going to be in the market for a whole new group of friends soon ... seeing as how you insulted A and cannot trust O. And word is going to get out quick that you're a gossip and a sneak and a liar, when people find out how you shiiiit-talked A behind her back. Find new friends, then do some serious work on yourself.
You've learned a hard lesson here. Don't talk shiiiiit about people (especially your friends) thinking that they'll never find out, because they will. And don't be dumb enough to provide proof of what you said, either.