Facebook data should be treated the same as letters or diaries, a court ruled.