First-principles approach to the electron-phonon interaction