精華 如何提交文章鏈接到必應快速收錄?附 IndexNow鏈接提交php代碼
近期觀察到Bing的搜索量顯著提升,為了更有效地對Bing進行SEO優化,我們考慮將最新的網站文章鏈接通過IndexNow接口提交給Bing,以促進其更快收錄。那么,如何使用PHP代碼實現將網站文章鏈接提交到Bing的IndexNow服務呢?
具體來說,我們需要編寫PHP代碼,實現向Bing的IndexNow接口提交網站文章鏈接的功能。
1、登錄https://www.bing.com/webmasters/必應站長平臺,添加網站并通過驗證。
2、進入https://www.bing.com/webmasters/indexnow點擊Get Started進入獲取key,并添加到網站根目錄下。
3、把下方php代碼復制到一個新建的php文件中,修改下網站域名、key、要提交的鏈接,保存放到php環境里運行即可。
<?php
$curl = curl_init();
$postdat = array(
'host' => 'yourdomain.com',
'key' => 'key',
'keyLocation' => 'http://yourdomain.com/key.txt',
'urlList' => array('http://yourdomain.com/1.html','http://yourdomain.com/2.html'),
);
$headers = array(
'Content-Type: application/json; charset=utf-8'
);
curl_setopt($curl, CURLOPT_URL,'https://api.indexnow.org/indexnow');
curl_setopt($curl, CURLOPT_POSTFIELDS,json_encode($postdat));
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($curl);
curl_close($curl);
echo '提交完成';