Contact Closure over distance
As Neil_ok says:  The bomb-proof way, up to many km distances, is a current-mode link, into an opto-isolator.

A simple solution is to make it difficult for external sources to put energy in your system. A very low input impedance helps with this. e.g. you can put a 220 Ohm resistor from the input to the ground. But in order to make the input high when the switch is open, you need now a much lower pull-up resistor too. Lets says about 82 Ohm which gives 220/(220+82)*3.3 = 2.4 Volts.
You can add Niel's capacitor too. 

The disadvantage is that this continuously uses 3.3/(220+82)= ~10mA.
When the switch is pressed, the 220 ohm resistor is shorted and  it uses 3.3/82 = ~ 40mA.