Update post title from external file?

Sometimes I use this code when I want to run WordPress externally.

update.php

function find_wordpress_base_path() {
    $dir = dirname(__FILE__);
    do {
        //it is possible to check for other files here
        if( file_exists($dir."/wp-config.php") ) {
            return $dir;
        }
    } while( $dir = realpath("$dir/..") );
    return null;
}

define( 'BASE_PATH', find_wordpress_base_path()."https://wordpress.stackexchange.com/" );
define('WP_USE_THEMES', false);
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header;
require(BASE_PATH . 'wp-load.php');

$post_id = $_POST['id'];
$title = $_POST['title'];

// Update post
$my_post = array(
    'ID'           => $post_id,
    'post_title'   => $title, // new title
);

// Update the post into the database
wp_update_post( $my_post );