As far as I can see, the example in the documentation is working, but not with the NASA JPL service. It says that NASA has stopped providing WMS support. You just have to look for another WMS service and fill in the required parameters:
urlWithParams = 'url=http://kaart.maaamet.ee/wms/alus&format=image/png&layers=MA-ALUS&styles=&crs=EPSG:3301'
rlayer = QgsRasterLayer(urlWithParams, 'MA-ALUS', 'wms')
QgsMapLayerRegistry.instance().addMapLayer(rlayer)
Be cautious, as if you don't fill out one of these parameters, because your WMS doesn't have one, QGIS will crash. In my example, the MA-ALUS
layer doesn't have a style attribute, but I had to include it as an empty parameter.
Result:

UPDATE:
It works with QGIS 2.6.0, yaay!
from qgis.core import *
urlWithParams = 'url=http://kaart.maaamet.ee/wms/alus&format=image/png&layers=MA-ALUS&styles=&crs=EPSG:3301'
rlayer = QgsRasterLayer(urlWithParams, 'MA-ALUS', 'wms')
QgsMapLayerRegistry.instance().addMapLayer(rlayer)
UPDATE for QGIS 3:
It works with QGIS 3.2, after accounting for a https://qgis.org/api/api_break.html -- yaay!
from qgis.core import *
urlWithParams = 'url=http://kaart.maaamet.ee/wms/alus&format=image/png&layers=MA-ALUS&styles=&crs=EPSG:3301'
rlayer = QgsRasterLayer(urlWithParams, 'MA-ALUS', 'wms')
QgsProject.instance().addMapLayer(rlayer)