I'm going to be straight up here, and say that if you hitch long enough, it's close to a 90%+ rate of running into harassment by police.
Like others have said, know your rights, the laws in each state you are going through, and how to hitch correctly (and as close to legally) as possible.
All of this info is posted in the 'Hitchhiking' section of this website.
If you don't have ID 90% of the time cops are going to ask for your name, date of birth, and state or origin. In my experience, if they can't identify you, or your info comes up obviously fake, they will detain you (if they have nothing better to do) until they can ID you.
The most hostile encounter with police hitching I've ever had, i was with another girl in Dublin, CA outside of Oakland, CA. They rolled up with hands on their guns, telling us to leave immediately. I quoted the CA law and stated that we were within our rights to be there. They put us in cuffs, ran our names, and they threatened jail if we were the longer than 5 minutes later. FUCK DUBLIN CA. Dont take the BART line out there to hitch.
Most of the time you're fine. Make sure you have a nice, big, legible sign with your destination on it. Most of the time I've heard people getting fucked with, its because the cops thought they were panhandling, which is still illegal in many areas to do from a roadway.
Be polite to the cops. Like i said in the last post about getting busted on trains. Talking shit or trying to flex your political views ain't going to get you nothing but a free ride to jail. It ain't worth it. That being said, know your rights, and when to use them.