2013-11-14 129 views
0

我嘗試ping谷歌,當我更新地圖,但總能得到響應「0」谷歌平失敗 - 捲曲

這裏就是我想:

$sitemapUrl = urlencode("http://testsite.com/Sitemap.xml"); 

// cUrl handler to ping the Sitemap submission URLs for Search Engines… 

function myCurl($url) { 

    $ch = curl_init($url); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_exec($ch); 
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    curl_close($ch); 
    return $httpCode; 

} 

//Google 
$url = "http: //www.google.com/webmasters/tools/ping?sitemap=".$sitemapUrl; 
$returnCode = myCurl($url); 
echo = "<p> Google Sitemaps has been pinged (return code: $returnCode). </p>"; 

將返回:

Google Sitemaps has been pinged (return code: 0). 
+2

您是否注意到協議後URL中的空格? – morgoth84

+0

@ morgoth84 Aaaargh我是個白癡!謝謝。 –

回答

0

您需要自Google運行在HTTPS/SSL protoc添加這些PARAMS醇。

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);