How can I write a script to add something to wp-config.php

I am trying to write a script to automatically set the post revisions for about 100 different sites to only store 5 revisions. The code I need to add to wp-config is as follows:

/*Optimization Stuff */
define('AUTOSAVE_INTERVAL', 120 ); // seconds (default is 60)
define('WP_POST_REVISIONS', 5); // alter number of post revisions kept.

Does anyone know how I might do this with PHP? I'm using ManageWP and I can send code snippets. I know how to change options, but I want to edit (or add to) the wp-config.php file. I know plugins do this (super cache for example), so I know it's possible. Any help pointing me in the right direction would be much appreciated. :slight_smile: