I don't have a problem with her checking his ID. I have a problem with the loitering charge just because he bugged her.
You shouldn't get a ticket for being a dummy. LEOs shouldn't be intelligence enforcers, or politeness enforcers. He was either loitering or he wasn't.
In my archair cowboy law opinion, he should have gotten a ticket for smoking, not for loitering. She saw him smoking, so she should have cited him for that. Why did she drop the smoking charges? She should have stuck to it if she saw it. I don't have all the facts, and I don't know her intentions, but it sure looks like she issued the ticket to make his life harder and punish him for being a jerk. They're Law Enforcement Officers, not Karma Enforcement Officers.
All that being said, I do think this guy was hoping to get harassed and to catch it on camera. He was a punk who wasn't respectful, but he didn't break any laws (that I know of) during the video. If he didn't break any laws, he shouldn't have been punished.