知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們在追求其視覺表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營銷的便利,運(yùn)營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏壧峁┍憬莸闹С郑?
給你的網(wǎng)站添加谷歌AMP、百度MIP、神馬MIP鏈接自動(dòng)提交功能
發(fā)表時(shí)間:2020-7-8
發(fā)布人:葵宇科技
瀏覽次數(shù):68
我們在做網(wǎng)站的時(shí)候,經(jīng)常會(huì)聽到別人說SEO優(yōu)化,網(wǎng)站優(yōu)化等等。但是我們經(jīng)常聽的云里霧里的,但是經(jīng)過我們運(yùn)營一段時(shí)間之后,我們慢慢的就會(huì)熟悉了,知道什么是SEO。
SEO中文譯名為搜索引擎優(yōu)化,既然是叫搜索引擎優(yōu)化,那么肯定的是從各個(gè)方面對網(wǎng)站的鏈接和內(nèi)容進(jìn)行優(yōu)化了。
在移動(dòng)互聯(lián)網(wǎng)高速發(fā)達(dá)的今天,僅僅只是依靠PC端的網(wǎng)頁展示是不夠的,還需要針對移動(dòng)端進(jìn)行優(yōu)化和展示,在這里我給大家普及一下,SEO的中AMP、MIP和熊掌號的幾個(gè)知識點(diǎn)。
1.AMP(Accelerated Mobile Pages),是谷歌的一項(xiàng)開放源代碼計(jì)劃,可在移動(dòng)設(shè)備上快速加載的輕便型網(wǎng)頁,旨在使網(wǎng)頁在移動(dòng)設(shè)備上快速加載并且看起來非常美觀。
2.MIP(Mobile Instant Page - 移動(dòng)網(wǎng)頁加速器),是一套應(yīng)用于移動(dòng)網(wǎng)頁的開放性技術(shù)標(biāo)準(zhǔn)。通過提供MIP-HTML規(guī)范、MIP-JS運(yùn)行環(huán)境以及MIP-Cache頁面緩存系統(tǒng),實(shí)現(xiàn)移動(dòng)網(wǎng)頁加速。
3.熊掌號,是百度熊掌號是內(nèi)容和服務(wù)提供者入駐百度生態(tài)的實(shí)名賬號。通過歷史內(nèi)容接口,每天可提交最多500萬條有價(jià)值的內(nèi)容,所提交內(nèi)容會(huì)進(jìn)入百度搜索統(tǒng)一處理流程。
好了,以上知識點(diǎn)內(nèi)容普及完了,接下來即將開始上干貨了。
我今天在網(wǎng)上使用站長工具查看本網(wǎng)站SEO信息的時(shí)候,看到幾個(gè)不常用的權(quán)重,其中就是神馬權(quán)重和頭條權(quán)重。
頭條的權(quán)重我不清楚,但是我知道他說的應(yīng)該是今日頭條,但是神馬權(quán)重,我就不是很清楚了,不知道神馬權(quán)重是啥,然后在百度上一搜索,才知道有一個(gè)神馬搜索引擎的。
好吧,雖然不知道這是一個(gè)什么樣的搜索引擎,但是既然是在站長工具上看到的,即使流量再小,也還是不要放過。
進(jìn)到神馬搜索引擎站長工具里面,我們會(huì)看到有站長相關(guān)的工具,其中有一欄為 MIP數(shù)據(jù)提交 。
既然有這個(gè)接口那我們就不要放過。
然后我們查看一下,如果使用PHP來做MIP數(shù)據(jù)的提交以及如何進(jìn)行判斷數(shù)據(jù)是否提交成功了。
使用PHP進(jìn)行MIP數(shù)據(jù)提交的代碼
$urls = array(
'http://www.example.com/1.html',
'http://www.example.com/2.html',
);
$api = 'http://data.zhanzhang.sm.cn/push?site=www.ddsiot.cn&[email protected]&resource_name=mip_add&token=xx';
$ch = curl_init();
$options = array(
CURLOPT_URL => $api,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => implode("\n", $urls),
CURLOPT_HTTPHEADER => array('Content-Type: text/plain'),
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
echo $result;
查看推送反饋:
推送成功:
{
"returnCode" : 200, //接收成功,但需要進(jìn)一步校驗(yàn)提交的內(nèi)容是否正確
"errorMsg" : ""
}
推送失?。?/div>
{
"returnCode" : 201, // 201: token不合法; 202: 當(dāng)日流量已用完; 400: 請求參數(shù)有誤; 500: 服務(wù)器內(nèi)部錯(cuò)誤
"errorMsg" : ""
}
嗯,我們已經(jīng)知道如何進(jìn)行MIP數(shù)據(jù)推送,也知道怎么判斷數(shù)據(jù)是否推送成功,我們現(xiàn)在針對Typecho的網(wǎng)站,添加一個(gè)MIP鏈接自動(dòng)提交的插件。
div class="row typecho-page-main" role="main">
<form action="<?php $options->adminUrl('extending.php?panel=AMP/Links.php&send=1'); ?>" method="POST">
<div class="operate" style="text-align: center;">
<select name="type" style="width:200px;text-align-last: center;">
<option value="amp">百度AMP</option>
<option value="mip">百度MIP</option>
<option value="smmip">神馬MIP</option>
<option value="batch">熊掌號</option>
</select>
<button type="submit" class="btn btn-s"><?php _e('開始提交'); ?></button>
</div>
</form>
<div>
我們制作的這個(gè)Typecho插件支持百度MIP、百度AMP、神馬MIP、熊掌號鏈接的自動(dòng)提交。
插件提交界面預(yù)覽:
插件提交結(jié)果提示代碼:
if (isset($_GET['send'])) {
$http = Typecho_Http_Client::get();
$db = Typecho_Db::get();
//URL分頁
if (isset($_GET['page'])) {
$page = (int)($_GET['page']);
} else {
$page = 1;
}
//URL類型
if ((isset($_GET['type']) and $_GET['type'] == 'amp') OR (isset($_POST['type']) and $_POST['type'] == 'amp')) {
$sendtype = 'amp';
$type = 'amp';
} elseif ((isset($_GET['type']) and $_GET['type'] == 'mip') OR (isset($_POST['type']) and $_POST['type'] == 'mip')) {
$sendtype = 'mip';
$type = 'mip';
} elseif ((isset($_GET['type']) and $_GET['type'] == 'smmip') OR (isset($_POST['type']) and $_POST['type'] == 'smmip')) {
$sendtype = 'mip';
$type = 'smmip';
} elseif ((isset($_GET['type']) and $_GET['type'] == 'batch') OR (isset($_POST['type']) and $_POST['type'] == 'batch')) {
$sendtype = 'mip';
$type = 'batch';
if (isset(Helper::options()->plugin('AMP')->baiduAPPID) and isset(Helper::options()->plugin('AMP')->baiduTOKEN)) {
$appid = Helper::options()->plugin('AMP')->baiduAPPID;
$token = Helper::options()->plugin('AMP')->baiduTOKEN;
$api = "http://data.zz.baidu.com/urls?appid={$appid}&token={$token}&type=batch";
} else {
throw new Typecho_Widget_Exception('未設(shè)置熊掌號參數(shù)!');
}
} else {
$sendtype = 'mip';
$type = 'mip';
}
$articleList = Typecho_Widget::widget('AMP_Action')->MakeArticleList($sendtype, $page, 20);
//接口類型
if (!isset($api))
{
if(('mip' == $type)||('amp' == $type) ||('batch' == $type))
{
if (empty(Helper::options()->plugin('AMP')->baiduAPI)) {
throw new Typecho_Widget_Exception('未設(shè)置MIP/AMP推送接口調(diào)用地址!');
} else {
$api = Helper::options()->plugin('AMP')->baiduAPI;
$api = preg_replace("/&type=[a-z]+/", "&type={$sendtype}", $api);//替換接口中的類型
}
}else if('smmip' == $type){
if (empty(Helper::options()->plugin('AMP')->SMAPI)) {
throw new Typecho_Widget_Exception('神馬未設(shè)置MIP推送接口調(diào)用地址!');
} else {
$api = Helper::options()->plugin('AMP')->SMAPI;
}
}
}
$urls = array();
foreach ($articleList AS $article) {
if(Helper::options()->plugin('AMP')->PostURL !== Helper::options()->index){
$article['permalink']=str_replace(Helper::options()->index,Helper::options()->plugin('AMP')->PostURL,$article['permalink']);//替換提交的前綴
}
echo '正在提交:' . $article['permalink'] . " <br>";
$urls[] = $article['permalink'];
}
if (count($urls) > 0) {
$http->setData(implode("\n", $urls));
$http->setHeader('Content-Type', 'text/plain');
try {
$result = $http->send($api);
} catch (Exception $e) {
throw new Typecho_Plugin_Exception(_t('對不起, 您的主機(jī)不支持遠(yuǎn)程訪問。<br>請檢查 curl 擴(kuò)展、allow_url_fopen和防火墻設(shè)置!<br><hr>出錯(cuò)信息:'.$e->getMessage()));
}
// string '{"remain":4999960,"success":0,"not_valid":[""]}'
// string '{"success_mip":20,"remain_mip":9980}' (length=36)
// $result='{"success_amp":20,"remain_amp":9980}';
// string(43) "{"success_batch":20,"remain_batch":4999960}"
$obj = json_decode($result, true);
if(('mip' == $type)||('amp' == $type) ||('batch' == $type))
{
$name = "success_{$type}";
if (isset($obj[$name])) {
echo '<hr>';
echo "第{$page}頁提交成功,";
print_r($obj);
$count = $obj["remain_{$type}"];
echo "還可提交{$count}條URL,準(zhǔn)備提交下一頁>>>";
$page += 1;
?>
<script language="JavaScript">
window.setTimeout("location='<?php $options->adminUrl('extending.php?panel=AMP/Links.php' . "&send=1&type={$type}&page={$page}");
?>'", 2000);
</script>
未自動(dòng)跳轉(zhuǎn)請點(diǎn)擊<a
href="<?php $options->adminUrl('extending.php?panel=AMP/Links.php' . "&send=1&type={$type}&page={$page}"); ?>">這里</a>
<?php
} else {
echo "<hr>錯(cuò)誤提示:";
print_r($obj);
echo "<br>提交失敗,請檢查提交地址。如有必要,請將錯(cuò)誤提示<a >反饋給作者</a>";
}
}else if('smmip' == $type)
{
if(200 == isset($obj["returnCode"] ))
{
echo '<hr>';
echo "第{$page}頁提交成功,";
echo "準(zhǔn)備提交下一頁>>>";
$page += 1;
?>
<script language="JavaScript">
window.setTimeout("location='<?php $options->adminUrl('extending.php?panel=AMP/Links.php' . "&send=1&type={$type}&page={$page}");
?>'", 2000);
</script>
未自動(dòng)跳轉(zhuǎn)請點(diǎn)擊<a
href="<?php $options->adminUrl('extending.php?panel=AMP/Links.php' . "&send=1&type={$type}&page={$page}"); ?>">這里</a>
<?php
}else{
echo "<hr>錯(cuò)誤提示:";
print_r($obj);
echo "<br>提交失敗,請檢查提交地址。如有必要,請將錯(cuò)誤提示<a >反饋給作者</a>";
}
}
} else {
echo "已全部提交完成";
?>
<script language="JavaScript">
window.setTimeout("location='<?php $options->adminUrl('extending.php?panel=AMP/Links.php');?>'", 2000);
</script>
未自動(dòng)跳轉(zhuǎn)請點(diǎn)擊<a href="<?php $options->adminUrl('extending.php?panel=AMP/Links.php'); ?>">這里</a>
<?php
}
插件神馬MIP提交結(jié)果預(yù)覽:
神馬MIP提交成功,大公告成。
插件源碼鏈接:https://www.ddsiot.cn/archives/310.html
如果評論之后,不能正常下載可以給我留言,也可以關(guān)注微信公眾號:ddiot,回復(fù):MIP插件,獲取下載鏈接。
使用方法:
將插件下載之后,放在Typecho的Plugins目錄下面,并將文件夾重命名為AMP。
————————————————
版權(quán)聲明:本文為CSDN博主「dwx1005526886」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/dwx1005526886/java/article/details/104029020
相關(guān)案例查看更多
相關(guān)閱讀
- .net網(wǎng)站
- 網(wǎng)站開發(fā)哪家好
- 云南網(wǎng)站建設(shè)哪家公司好
- 云南網(wǎng)頁制作
- 網(wǎng)站建設(shè)
- 云南手機(jī)網(wǎng)站建設(shè)
- 關(guān)鍵詞快速排名
- 云南小程序被騙
- web前端
- 報(bào)廢車拆解軟件
- 報(bào)廢車
- 云南網(wǎng)站建設(shè)方案 doc
- Web開發(fā)框架
- 英文網(wǎng)站建設(shè)公司
- 生成海報(bào)
- 百度人工排名
- 網(wǎng)站收錄
- 云南網(wǎng)站建設(shè)快速優(yōu)化
- 昆明網(wǎng)站建設(shè)公司
- 云南etc小程序
- 商標(biāo)注冊
- 網(wǎng)站建設(shè)高手
- 汽車拆解管理軟件
- 汽車報(bào)廢回收管理軟件
- 網(wǎng)站建設(shè)靠譜公司
- 汽車報(bào)廢回收
- 百度小程序開發(fā)
- 云南網(wǎng)站建設(shè)案例
- 海南小程序制作公司
- 網(wǎng)絡(luò)公司電話