VIP福利
主页 > 建站问题 > 程序开发 > 织梦DedeCMS MIP数据API接口提交开发教程

织梦DedeCMS MIP数据API接口提交开发教程

MIP是Mobile Instant Pages的缩写,指百度移动网页加速器, 是一套应用于移动网页的开放性技术标准。通过提供MIP-HTML规范、MIP-JS运行环境以及MIP-Cache页面缓存系统,实现移动网页加速。 […]



MIP是Mobile Instant Pages的缩写,指百度移动网页加速器, 是一套应用于移动网页的开放性技术标准。通过提供MIP-HTML规范、MIP-JS运行环境以及MIP-Cache页面缓存系统,实现移动网页加速。

MIP改造

MIP HTML 基于HTML中的基础标签制定了全新的规范,通过对一部分基础标签的使用限制或功能扩展,使HTML能够展现更加丰富的内容;MIP JS 可以保证 MIP HTML 页面的快速渲染;MIP Cache 用于实现MIP页面的高速缓存,从而进一步提高页面性能。

下面是织梦DedeCMS提交mip数据API接口教程

在根目录下新建一个baidu_mip.php文件,把下面的代码粘贴进去,这个API接口做的是旧URL的提交,适合已经做了MIP改造的网站。设置时间为2018年11月11日,请根据自己的实际情况调整。

<?php
/*
*MIP改造提交数据API接口
*by 织梦帮 www.dedesos.com
*2019.4月
*/
require_once ("include/common.inc.php");
require_once "include/arc.partview.class.php";
require_once('include/charset.func.php');
$year = date("Y");
$month = date("m");
$day = date("d");
$dayBegin = mktime(0,0,0,04,11,2019);//开始时间2019年04月11日
$dayEnd = mktime(23,59,59,$month,$day,$year);
$query = "SELECT arch.id,types.typedir FROM dede_arctype as types inner join dede_archives as arch on types.id=arch.typeid where pubdate<".$dayEnd." AND pubdate>".$dayBegin."";
$urls="";
$dsql->Execute('arch.id,types.typedir',$query);
while($row = $dsql->GetArray('arch.id,types.typedir'))
{
$urls.="https://www.dedesos.com/mip".str_replace("{cmspath}","",$row['typedir'])."/".$row[id].".html".",";//静态URL,自行修改
}
echo "URL:<br>".str_replace(",","<br>",$urls); //打印所有提交的数据
$urls=substr($urls,0,-1);
$urls = explode(",",$urls);
$api = 'http://data.zz.baidu.com/urls?site=xxx&token=xxx&type=mip';//API接口自行修改
$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;
?>

访问http://域名/baidu_mip.php即可提交MIP数据,如果提交的URL没有问题,就会顺利通过,大家可以在站长工具后台查看“错误反馈”,时间上有些滞后,耐心等两天吧。提交数据的MIP化比例需维持在50%,否则失去该项得分。

MIP数据

↑MIP数据提交成功


说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!