Thermostats outputs to GPIO then to Furnace
First thing to do is find out if you have black (ground) wire available.

If you do, then make sure you have other colors right by operating thermostat and measuring voltage between other wires and ground. Standard pinout is G-fan, W-heat, Y-AC. The voltage should appear on the wire when corresponding function activated.

If you don't have ground (which is usually the case) then measure between red (24VAC) and G/W/Y. In this case the output is reversed - you should see some voltage when function is not active, and 0 when it is activated.

How exactly you use them depends on the availability of ground wire and location of you wiretap. If you placing this near the furnace you might be able to bring ground out of it, so the second case becomes the first. If this is not possible you'd have to disconnect red wire from furnace and supply your own DC (e.g. +5V) to it. (normally I'd recommend connecting it to GND, but if thermostat uses solid-state relays it might not work)

The best way to convert AC into I/O is by using optocouplers connected between G/W/Y and black wires. See here or here for examples. Or, even better, use AC optocoupler like H11AA1M, HCPL3700 to simplify circuit a lot.

If you had to disconnect red and supply your own DC then you can connect return wires from thermostat to I/O, with some resistors in series and pull-downs. However I would recommend using optocouplers on inputs anyway, to isolate your controller from whatever currents might lurk in your wiring.

Please, take the standard precautions when working on mains-powered appliances.