We frequently measure the "temperature of the Sun" using Wien law: $\lambda_m T = b$ where $b$ is the displacement constant, $\lambda_m$ is the peak wavelength obtained from the spectrum, and $T$ is the corresponding temperature. Using this method $T$ comes out to be ~$6000$ K - which is the surface temperature of the Sun, obviously. So, is there any physical reason that we are getting the surface temperature of the Sun, and not getting the interior temperature of the Sun, by this method? Also, is there any way by which interior temperature can be measured using Wien law or Blackbody radiation theory?
Most of the radiation emitted by the inner parts of the star has to pass through a lot more matter than the ones emitted near the surface. Thus most of the inner radiation is either trapped or absorbed before coming out of the star. This is why most of the light we see of stars consist of emissions from near the surface. And this is why we get information about just the surface temperature.
And as for how the core temperature can be measured you can look up this answer as I am not an expert in this field.