you need to purchase from an Apple authorized reseller. A majority of on-line sellers are not authorized resellers so if you buy an iOS device from Amazon.com for instance you are not the original owner and your warranty began with original purchaser (who is also the technical owner) bought or obtained the device from Apple, so if you "buy" a phone that a reseller bought over a year ago you are buying one that has no warranty any longer, even if it was shipped in a new box wrapped in plastic and never opened.
Call l1-800-MY-APPLE in North America or go to apple.com/contact for a list of international phone numbers to find an Apple reseller near you.