An appeals court in the United States overnight ruled that the NSA's mass collection of Americans' phone records was illegal and not authorised by the US government.