HomeBridge has a plugin for simple relay-plus-sensor configurations like this. One GPIO pin is a relay trigger and the other is a sensor pin.
It's important to insure that the Pi is isolated from from the opener. To that end, a reed relay controlled by an N MOSFET is sufficient for a garage door button.
A typical magnetic sensor is a switch closing, not unlike a relay. While it's sufficient to simply use a pull-up and switch it against ground, it's slightly safer to do something like MIDI - set up an opto isolator to capture the switch closing and translate that into a logic level for the Pi.
On the software side, I've used HomeBridge to talk to the service behind a Chamberlain gateway, and that works pretty well (EDIT: well, it did until this week. Check out the logs). Our new home comes with a Genie garage door opener, and I was considering buying their Aladdin internet connection gizmo. The problem with that, though, is that it's essentially a relay and a sensor. So it's really not any better than just doing it this way, but you're paying extra and adding an extra Internet layer for little gain.
Nick Sayer
Alan Chambers
Julius Curt
Tobias
Gareth Coleman