On a theorem of Halphen and its application to integrable systems