您现在的位置是:首页 > 教程 > 帝国CMS教程帝国CMS教程
帝国CMS百度主动提交URL和熊掌号提交的方法
怀蕊2023-05-26 19:48:30帝国CMS教程已有人查阅
导读帝国CMS百度主动提交URL和熊掌号修改方法,首先打开ecmsinfo.php,添加以下代码,打开listinfo.php ,添加提交按钮代码
帝国CMS百度主动提交URL和熊掌号修改方法,首先打开ecmsinfo.php,添加以下代码
elseif($enews == "Post_Baidu_sitemap") //文章实时发送百度
{
$id = $_POST['id'];
$urls = $_POST['titleurl'];
ePostBaiduSitemap($id, $urls);
}
elseif($enews == "Post_realtime") //熊掌号新增内容接口
{
$id = $_POST['id'];
$urls = $_POST['titleurl'];
ePostrealtime($id, $urls);
}
elseif($enews == "Post_batch") //熊掌号历史内容接口
{
$id = $_POST['id'];
$urls = $_POST['titleurl'];
ePostrealtime($id, $urls);
}
打开listinfo.php ,添加提交按钮代码
< input type = "submit" name = "Submit101" value = "百度URL主动提交" onClick = "document.listform.enews.value='Post_Baidu_sitemap';document.listform.action='ecmsinfo.php';" >
< input type = "submit" name = "Submit52" value = "熊掌号新增内容" onClick = "document.listform.enews.value='Post_realtime';document.listform.action='ecmsinfo.php';" >
< input type = "submit" name = "Submit102" value = "熊掌号历史内容" onClick = "document.listform.enews.value='Post_batch';document.listform.action='ecmsinfo.php';" >
打开userfun.php,,添加提交函数
//发送给百度时时更新-------------------------------
function ePostBaiduSitemap($id, $_urls) {
$site = 'https://www.pc07.com'; //你的网站域名
$token = 'JG43q1HpKMWiNQ3D'; //百度给的token
$countcount = count($id);
if (empty($count)) {
printerror("未选择信息ID", "", 1, 0, 1);
}
$urls = array();
for ($i = 0; $i < $count; $i++) {
$id[$i] = (int) $id[$i];
if (array_key_exists($id[$i], $_urls)) {
$urls[] = $_urls[$id[$i]];
}
}
$api = "http://data.zz.baidu.com/urls?site=$site&token=$token";
$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);
$httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpstat == 200) {
$obj = json_decode($result);
printerror("今天剩余{$obj->remain}条,成功提交{$obj->success}条", "", 1, 0, 1);
} else {
printerror('推送失败', "", 1, 0, 1);
}
}
//熊掌号新增内容接口
function ePostrealtime($id, $_urls) {
$site = 'https://www.pc07.com'; //你的网站域名
$token = 'HUuRZYgrlGLrVysh'; //在搜索资源平台申请的推送用的准入密钥
$appid = '1585197816243468'; //您的熊掌号唯一识别ID
$countcount = count($id);
if (empty($count)) {
printerror("未选择信息ID", "", 1, 0, 1);
}
$urls = array();
for ($i = 0; $i < $count; $i++) {
$id[$i] = (int) $id[$i];
if (array_key_exists($id[$i], $_urls)) {
$urls[] = $_urls[$id[$i]];
}
}
$api = "http://data.zz.baidu.com/urls?appid=$appid&token=$token&type=realtime";
$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);
$httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpstat == 200) {
$obj = json_decode($result);
printerror("今天剩余{$obj->remain_realtime}条,成功提交{$obj->success_realtime}条", "", 1, 0, 1);
} else {
printerror('推送失败', "", 1, 0, 1);
}
}
//熊掌号历史内容接口
function ePostbatch($id, $_urls) {
$site = 'https://www.pc07.com'; //你的网站域名
$token = 'HUuRZYgrlGLrVysh'; //在搜索资源平台申请的推送用的准入密钥
$appid = '1585197816243468'; //您的熊掌号唯一识别ID
$countcount = count($id);
if (empty($count)) {
printerror("未选择信息ID", "", 1, 0, 1);
}
$urls = array();
for ($i = 0; $i < $count; $i++) {
$id[$i] = (int) $id[$i];
if (array_key_exists($id[$i], $_urls)) {
$urls[] = $_urls[$id[$i]];
}
}
$api = "http://data.zz.baidu.com/urls?appid=$appid&token=$token&type=batch";
$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);
$httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpstat == 200) {
$obj = json_decode($result);
printerror("今天剩余{$obj->remain_batch}条,成功提交{$obj->success_batch}条", "", 1, 0, 1);
} else {
printerror('推送失败', "", 1, 0, 1);
}
}
本文标签:
很赞哦! ()
相关文章
随机图文
-
帝国CMS7.2兼容多种终端访问的方法
帝国CMS7.2版别多终端拜访功用更完善,改善如下:1、能够设置主拜访端为静态,其它拜访端为动态(也能够有些端静态,有些端动态),使其它拜 -
帝国cms数据表phome_enewsmoreport端口表介绍
phome_enewsmoreport端口表字段名字段类型解释pidint(11)pnamechar(60)purlchar(255)ppathchar(255)postpasschar(120) -
帝国CMS教程模板导入导出的好处,帝国CMS模板导入导出教程
模板导入导出三大好处:1、模板共享更加方便。2、可多模板并存。3、随时更换网站模板。4、单个ECMS数据,多站点模板。 -
帝国CMS怎么整合Discuz,帝国CMS和Discuz双向同步登录退出的方法
用帝国CMS6.6整合安装Discuz!7.2。为了便于以后的升级扩展。决定整合ucenter1.5。首先安装 “Discuz_7.2_FULL_SC_GBK”也就是已经包含ucenter1.5的Discuz7.2版本
留言与评论 (共有 条评论) |