If you have ever backed up your iPhone via iTunes or iCloud, you can restore iPhone from the backup. iTunes and iCloud allow you to restore iPhone SMS, contacts, calendars, notes and settings directly from iTunes backup. After that, all of your iPhone data will be replaced by the old data in your backup folder. http://support.apple.com/kb/ht1766
Recover iPhone without backup, or if you only want your text messages and photos back, you may have to turn to some third party software for help. Even if you donít have any backup files, they can help you find your text messages and photos back.
More resource here:
How to recover deleted photos from my iPhone
How to recover deleted text messages from my iPhone