Baidu takes the initiative to push high-quality content directly to Baidu to speed up the collection
preface
function code
function _baidu_tuisong($post_ID){ global $post; If (function_exists ('curl_init ')) {//Judge whether curl extension is enabled $_tuisong_site='Enter your domain name again, such as. me, without http://'; $_tuisong_token='Enter your key here '; if( empty($post_ID) || empty($_tuisong_site) || empty($_tuisong_token) ) return; $api = ' http://data.zz.baidu.com/urls?site= '.$_ Tuisong_site. '&token='. $_tuisong_token;//Baidu's official API If ($post ->post_status="publish") {//Only published articles $url = get_permalink($post_ID); $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $url, CURLOPT_HTTPHEADER => array('Content-Type: text/plain') ); curl_setopt_array($ch, $options); } } } add_action('publish_post', '_baidu_tuisong', 0);
Precautions
Postscript