Easiest way to simulate WordPress’s URL resolution to retrieve post ID, etc?

As Weston mentioned, if you’re within WordPress and you know what blog the URL came from, then ask WordPress for the blog ID.

But if you’re really, really sure there’s no better method in this case than parsing a URL, then here you go:

$url="http://myblog.mysite.com/2012/03/16/whatever/";

$domain = parse_url( $url, PHP_URL_HOST );

// This could be dynamic but good enough for now
$subdomain = str_replace( '.mysite.com', '', $domain );

// Never use $blog_id for anything, you'll break tons of things
$parsed_blog_id = get_id_from_blogname( $subdomain );


// url_to_postid() only works for the current blog
switch_to_blog( $parsed_blog_id );

$post_id = url_to_postid( $url );

restore_current_blog();

Reference material:

http://codex.wordpress.org/Function_Reference/get_id_from_blogname

http://codex.wordpress.org/Function_Reference/url_to_postid