Ultimate Combat has a feat line called Snap Shot (then Improved, then Greater).
Snap Shot
Prerequisites: Dex 13, Point-Blank Shot, Rapid Shot, Weapon Focus, base attack bonus +6
Benefit: While wielding a ranged weapon with which you have Weapon Focus, you threaten squares within 5 feet of you. You can make attacks of opportunity with that ranged weapon. You do not provoke attacks of opportunity when making a ranged attack as an attack of opportunity.
Combine this with Point Blank Master and unless I'm wrong, it seems that you can do everything flanking with ranged as you would with a melee weapon.