A U.S. appeals court has rejected the National Security Agency's bulk collection of American's telephone records.