I'm not sure if this helps, but i recently unlocked my iPhone 3GS by calling AT&T and confirming that I was beyond my 2-year contract. After that, they contact Apple, Apple eventually provided the unlock code (actually I think they unlocked the phone remotely) and then I had to do a reset in iTunes with the phone connected, and it became unlocked. If you bought a used Iphone 3GS, seems like it would be out of contract and you could do the same thing, or maybe just call Apple directly, provide the serial number and they'll unlock it.