alright so the following 2 lines added in the require block made it work for me:
wp_set_current_user(0,"wp_admin"); //pretend it is the network admin doing this, since regular user can't
require_once('wp-admin/includes/admin.php'); //load the prefixes for database tables
Did you have any luck with this? I had the same problem and found that requiring wp-admin/network/admin.php does the trick. However, that requires an admin to be logged in, which is not really what I wanted.