Ciampoli, Giovanni, Papal secretary and poet