帝國CMS百度主動(dòng)提交URL和熊掌號(hào)修改方法,首先打開ecmsinfo.php,添加以下代碼
elseif($enews == "Post_Baidu_sitemap") //文章實(shí)時(shí)發(fā)送百度 { $id = $_POST['id']; $urls = $_POST['titleurl']; ePostBaiduSitemap($id, $urls); } elseif($enews == "Post_realtime") //熊掌號(hào)新增內(nèi)容接口 { $id = $_POST['id']; $urls = $_POST['titleurl']; ePostrealtime($id, $urls); } elseif($enews == "Post_batch") //熊掌號(hào)歷史內(nèi)容接口 { $id = $_POST['id']; $urls = $_POST['titleurl']; ePostrealtime($id, $urls); }
打開listinfo.php ,添加提交按鈕代碼
< input type = "submit" name = "Submit101" value = "百度URL主動(dòng)提交" onClick = "document.listform.enews.value='Post_Baidu_sitemap';document.listform.action='ecmsinfo.php';" > < input type = "submit" name = "Submit52" value = "熊掌號(hào)新增內(nèi)容" onClick = "document.listform.enews.value='Post_realtime';document.listform.action='ecmsinfo.php';" > < input type = "submit" name = "Submit102" value = "熊掌號(hào)歷史內(nèi)容" onClick = "document.listform.enews.value='Post_batch';document.listform.action='ecmsinfo.php';" >
打開userfun.php,,添加提交函數(shù)
//發(fā)送給百度時(shí)時(shí)更新------------------------------- function ePostBaiduSitemap($id, $_urls) { $site = 'https://www.pc07.com'; //你的網(wǎng)站域名 $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); } } //熊掌號(hào)新增內(nèi)容接口 function ePostrealtime($id, $_urls) { $site = 'https://www.pc07.com'; //你的網(wǎng)站域名 $token = 'HUuRZYgrlGLrVysh'; //在搜索資源平臺(tái)申請(qǐng)的推送用的準(zhǔn)入密鑰 $appid = '1585197816243468'; //您的熊掌號(hào)唯一識(shí)別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); } } //熊掌號(hào)歷史內(nèi)容接口 function ePostbatch($id, $_urls) { $site = 'https://www.pc07.com'; //你的網(wǎng)站域名 $token = 'HUuRZYgrlGLrVysh'; //在搜索資源平臺(tái)申請(qǐng)的推送用的準(zhǔn)入密鑰 $appid = '1585197816243468'; //您的熊掌號(hào)唯一識(shí)別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); } }
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: 帝國CMS百度主動(dòng)提交URL和熊掌號(hào)修改方法