精華 如何提交文章鏈接到必應(yīng)快速收錄?附 IndexNow鏈接提交php代碼
近期觀察到Bing的搜索量顯著提升,為了更有效地對(duì)Bing進(jìn)行SEO優(yōu)化,我們考慮將最新的網(wǎng)站文章鏈接通過IndexNow接口提交給Bing,以促進(jìn)其更快收錄。那么,如何使用PHP代碼實(shí)現(xiàn)將網(wǎng)站文章鏈接提交到Bing的IndexNow服務(wù)呢?
具體來說,我們需要編寫PHP代碼,實(shí)現(xiàn)向Bing的IndexNow接口提交網(wǎng)站文章鏈接的功能。
1、登錄https://www.bing.com/webmasters/必應(yīng)站長平臺(tái),添加網(wǎng)站并通過驗(yàn)證。
2、進(jìn)入https://www.bing.com/webmasters/indexnow點(diǎn)擊Get Started進(jìn)入獲取key,并添加到網(wǎng)站根目錄下。
3、把下方php代碼復(fù)制到一個(gè)新建的php文件中,修改下網(wǎng)站域名、key、要提交的鏈接,保存放到php環(huán)境里運(yùn)行即可。
<?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 '提交完成';