Can't create node programmatically
To bootstrap, try adding the following lines of code to the top of your custom-posts.php file:

$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
define('DRUPAL_ROOT', '/var/www/drupal7');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


Don't forget to update the path to your Drupal root folder.