The easiest way is to simply use my HubDuino project to handle this. I even have an example sketch for controlling a garage door from an ESP8266.