首页站内杂志技术文摘
文章内容页

帝国CMS百度主动提交URL和熊掌号修改方法

  • 作者:雨祺
  • 来源: 原创
  • 发表于2022-02-06 21:05:23
  • 阅读0
  • 帝国CMS百度主动提交URL和熊掌号修改方法,首先打开ecmsinfo.php,添加以下代码
    1. elseif($enews == "Post_Baidu_sitemap"//文章实时发送百度   
    2.     $id = $_POST['id']; 
    3.     $urls = $_POST['titleurl']; 
    4.     ePostBaiduSitemap($id, $urls); 
    5. elseif($enews == "Post_realtime"//熊掌号新增内容接口   
    6.     $id = $_POST['id']; 
    7.     $urls = $_POST['titleurl']; 
    8.     ePostrealtime($id, $urls); 
    9. elseif($enews == "Post_batch"//熊掌号历史内容接口   
    10.     $id = $_POST['id']; 
    11.     $urls = $_POST['titleurl']; 
    12.     ePostrealtime($id, $urls); 
    打开listinfo.php ,添加提交按钮代码
    1. < input type = "submit" name = "Submit101" value = "百度URL主动提交" onClick = "document.listform.enews.value='Post_Baidu_sitemap';document.listform.action='ecmsinfo.php';" >  
    2. < input type = "submit" name = "Submit52" value = "熊掌号新增内容" onClick = "document.listform.enews.value='Post_realtime';document.listform.action='ecmsinfo.php';" >  
    3. < input type = "submit" name = "Submit102" value = "熊掌号历史内容" onClick = "document.listform.enews.value='Post_batch';document.listform.action='ecmsinfo.php';" > 
    打开userfun.php,,添加提交函数
    1. //发送给百度时时更新-------------------------------   
    2. function ePostBaiduSitemap($id, $_urls) { 
    3.     $site = 'https://www.pc07.com'; //你的网站域名   
    4.     $token = 'JG43q1HpKMWiNQ3D'//百度给的token   
    5.     $countcount = count($id); 
    6.     if (empty($count)) { 
    7.         printerror("未选择信息ID""", 1, 0, 1); 
    8.     } 
    9.     $urls = array(); 
    10.     for ($i = 0; $i < $count; $i++) { 
    11.         $id[$i] = (int) $id[$i]; 
    12.         if (array_key_exists($id[$i], $_urls)) { 
    13.             $urls[] = $_urls[$id[$i]]; 
    14.         } 
    15.     } 
    16.     $api = "http://data.zz.baidu.com/urls?site=$site&token=$token"
    17.     $ch = curl_init(); 
    18.     $options = array(CURLOPT_URL = > $api, CURLOPT_POST = > true, CURLOPT_RETURNTRANSFER = > true, CURLOPT_POSTFIELDS = > implode("n", $urls), CURLOPT_HTTPHEADER = > array('Content-Type: text/plain'), ); 
    19.     curl_setopt_array($ch, $options); 
    20.     $result = curl_exec($ch); 
    21.     $httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    22.     curl_close($ch); 
    23.     if ($httpstat == 200) { 
    24.         $obj = json_decode($result); 
    25.         printerror("今天剩余{$obj->remain}条,成功提交{$obj->success}条""", 1, 0, 1); 
    26.     } else { 
    27.         printerror('推送失败'"", 1, 0, 1); 
    28.     } 
    29. //熊掌号新增内容接口   
    30. function ePostrealtime($id, $_urls) { 
    31.     $site = 'https://www.pc07.com'; //你的网站域名   
    32.     $token = 'HUuRZYgrlGLrVysh'//在搜索资源平台申请的推送用的准入密钥   
    33.     $appid = '1585197816243468'//您的熊掌号唯一识别ID   
    34.     $countcount = count($id); 
    35.     if (empty($count)) { 
    36.         printerror("未选择信息ID""", 1, 0, 1); 
    37.     } 
    38.     $urls = array(); 
    39.     for ($i = 0; $i < $count; $i++) { 
    40.         $id[$i] = (int) $id[$i]; 
    41.         if (array_key_exists($id[$i], $_urls)) { 
    42.             $urls[] = $_urls[$id[$i]]; 
    43.         } 
    44.     } 
    45.     $api = "http://data.zz.baidu.com/urls?appid=$appid&token=$token&type=realtime"
    46.     $ch = curl_init(); 
    47.     $options = array(CURLOPT_URL = > $api, CURLOPT_POST = > true, CURLOPT_RETURNTRANSFER = > true, CURLOPT_POSTFIELDS = > implode("n", $urls), CURLOPT_HTTPHEADER = > array('Content-Type: text/plain'), ); 
    48.     curl_setopt_array($ch, $options); 
    49.     $result = curl_exec($ch); 
    50.     $httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    51.     curl_close($ch); 
    52.     if ($httpstat == 200) { 
    53.         $obj = json_decode($result); 
    54.         printerror("今天剩余{$obj->remain_realtime}条,成功提交{$obj->success_realtime}条""", 1, 0, 1); 
    55.     } else { 
    56.         printerror('推送失败'"", 1, 0, 1); 
    57.     } 
    58. //熊掌号历史内容接口   
    59. function ePostbatch($id, $_urls) { 
    60.     $site = 'https://www.pc07.com'; //你的网站域名   
    61.     $token = 'HUuRZYgrlGLrVysh'//在搜索资源平台申请的推送用的准入密钥   
    62.     $appid = '1585197816243468'//您的熊掌号唯一识别ID   
    63.     $countcount = count($id); 
    64.     if (empty($count)) { 
    65.         printerror("未选择信息ID""", 1, 0, 1); 
    66.     } 
    67.     $urls = array(); 
    68.     for ($i = 0; $i < $count; $i++) { 
    69.         $id[$i] = (int) $id[$i]; 
    70.         if (array_key_exists($id[$i], $_urls)) { 
    71.             $urls[] = $_urls[$id[$i]]; 
    72.         } 
    73.     } 
    74.     $api = "http://data.zz.baidu.com/urls?appid=$appid&token=$token&type=batch"
    75.     $ch = curl_init(); 
    76.     $options = array(CURLOPT_URL = > $api, CURLOPT_POST = > true, CURLOPT_RETURNTRANSFER = > true, CURLOPT_POSTFIELDS = > implode("n", $urls), CURLOPT_HTTPHEADER = > array('Content-Type: text/plain'), ); 
    77.     curl_setopt_array($ch, $options); 
    78.     $result = curl_exec($ch); 
    79.     $httpstat = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
    80.     curl_close($ch); 
    81.     if ($httpstat == 200) { 
    82.         $obj = json_decode($result); 
    83.         printerror("今天剩余{$obj->remain_batch}条,成功提交{$obj->success_batch}条""", 1, 0, 1); 
    84.     } else { 
    85.         printerror('推送失败'"", 1, 0, 1); 
    86.     } 
    【审核人:站长】

        标题:帝国CMS百度主动提交URL和熊掌号修改方法

        本文链接:https://www.wenyunfang.com/zazhi/zhongwangjiaocheng/66.html

        赞一下

        深度阅读

        • 您也可以注册成为文韵坊的作者,发表您的原创作品、分享您的心情!

        阅读记录

          关注文韵坊