The unlock code can be obtained by calling where the phone is locked to.
For example, if it's locked to AT&T just called them, and they will provide you the code, if you told them you have used the phone for a long time and you had AT&T before, but not anymore. It worked for me when I called...