Every object emits some form of electromagnetic radiation.
The hotter it gets, the higher the energy of the radiation it gives off. This ranges from low energy, infrared radiation for cool objects, to high energy, ultra violet radiation and beyond, as the object gets very hot. A body at a certain temperature gives off a unique pattern of radiation. So it's quite simple to measure the type of electromagnetic radiation given off from a planet to get an exact measurement of the temperature. The electromagnetic radiation given off from a planet can also help us to understand its atmosphere.