Temperature can be measured by direct contact or inferred by the quality and quantity of radiation being received by the object. There is a further complication when using the inferred method, is the object radiating blackbody radiation or is it being produced by some other process.
Go to bing.com and click “Images” and search
cmb graph cobe
You will see that the CMB impressively follows the black body curve. One graph is logarithmic and shows it is BB over 3 orders of magnitude of frequency.
The CMB has even more complications. What is the distance, what was the original wavelengths before the expansion of the universe redshifted it, etc.
The distance is not important since there is little absorption through space. It is the fit to a BB curve that is important. Distance won't change it. All frequencies are red-shifted the same so the BB curve is likewise shifted from a very high temperature.
The CMB is given a 'temperature' of 2.7K but it is not a temperature in the common meaning of the word.
It actually is a temperature in the common meaning of temperature. The following is from the site
Brief History of the Universe
0.0001 seconds after the Big Bang the temperature of the universe was about T=1013 K.
One month after the Big Bang the processes that convert the radiation field to a
blackbody spectrum become slower than the expansion of the Universe, so the spectrum of the Cosmic Microwave Background (CMB) preserves information back to this time. Temperature is T=3000 K, time is 380,000 years after the Big Bang.
The red-shift brings it down to 2.7 K.
Closer to home, polarbear tried to point out that the solar insolation reaching the surface is equivalent to minus 60C, if you put it into the S-B equation. Ridiculous right? Where is the error? Not taking the distance into account, the inverse square law.
I don't know exactly what he was referring to, but I think you are right. Not only do you have to consider distance, but you also have to consider sun size. See below.
This is where SSDD mocked me for saying the S-B equation deals with two dimensional objects (area) imbedded in a three dimensional space. Radiation from a surface spreads out in three dimensions. The radiation being passed from one object to another is attenuated by the inverse square law, only some of the radiation produced by Area1 arrives at Area2.
The SB equation works well when an object at one temperature is completely surrounded by another object at another uniform temperature. If the background is a smaller object the distance and subtended solid angle must be considered. In a 3-D configuration with several objects at various distances and temperatures the SB equation is very difficult to apply and would have to be done with numerical integration.