Submitting your Sitemap via an HTTP request

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Submitting your Sitemap via an HTTP request

Post by hawleyjr »

I came across this section while reading sitemaps.org

http://www.sitemaps.org/protocol.php#submit_ping
To submit your Sitemap using an HTTP request (replace <searchengine_URL> with the URL provided by the search engine), iIssue your request to the following URL:

<searchengine_URL>/ping?sitemap=sitemap_url
So I tried it with Google, Yahoo and Live. But was unable to get any of them to work.

Here is what I tried:

Code: Select all

function submitSiteMapToSearchEngine( $search_engine,$sitemap_url ){

	$url = $search_engine . '/ping?sitemap=' . urlencode( $sitemap_url );
	 
	echo '<hr>Get URL:<br>' . $url;


	$ch=curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
	echo curl_exec ($ch);
	$headers = curl_getinfo($ch);
	echo '<HR><PRE>'; print_r($headers); echo '</PRE>';
	curl_close ($ch);


}	

submitSiteMapToSearchEngine( 'http://www.google.com','http://www.example.com/sitemapindex.xml' );
Has anyone else tried to do this?

Result of the above (With a different domain used)

Code: Select all

Array
(
    [url] => http://www.google.com/ping?sitemap=http%3A%2F%2Fwww.example.com%2Fsitemapindex.xml
    [content_type] => text/html
    [http_code] => 404
    [header_size] => 127
    [request_size] => 120
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.223
    [namelookup_time] => 0
    [connect_time] => 0.024
    [pretransfer_time] => 0.025
    [size_upload] => 0
    [size_download] => 1415
    [speed_download] => 6345
    [speed_upload] => 0
    [download_content_length] => 1415
    [upload_content_length] => 0
    [starttransfer_time] => 0.223
    [redirect_time] => 0
)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Nice! Thanks Volka.

Anyone know if MSN or Yahoo offer this also?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Did you use the search engines to saerch their own site for this information?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

volka wrote:Did you use the search engines to saerch their own site for this information?
Lol, yeah I have. I've been all over them. I've even searched google for yahoo, yahoo for google. etc... I found some information but not this specific information. Searching a search engine for submit sitemap...returns quite a bit of junk. (Especially on MSN)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Thanks a ton for the help Volka

For anyone who searches like it do... :oops: I found a complete list here:

http://en.wikipedia.org/wiki/Sitemaps#S ... r_Sitemaps
Post Reply