WordPress program Baidu quick collection API submission code and tutorial
WattsBlogger of Watts
Release your eyes, put on your headphones and listen~!
Baidu search resources mobile zone is ready to close what is going on?I believe everyone is familiar with Baidu Search Resources Mobile Zone, but what is going on when Baidu Search Resources Mobile Zone is going to close? Let's let Xiao Bian lead you to understand.
Add the following code to the appropriate place in the functions.php file of the theme currently used by your WordPress, and change the API address in the code to the one you use on Baidu Search Resource PlatformFast recordingAPI interface address.
//WordPress Baidu quick collection API submission codeadd_action('save_post','fanly_baidu_dailysubmit',ten,three);functionfanly_baidu_dailysubmit($post_id,$post,$update){if($post->post_status!='publish'||get_post_meta($post_id,'Fanly_Submit',true)=='OK')return;$api='http://data.zz.baidu.com/urls?site=https://zhangzifan.com/&token=c4LbbowRJZmedaam&type=daily';//Quick recording and copying$response=wp_remote_post($api,array('headers'=>array('Accept-Encoding'=>'','Content-Type'=>'text/plain'),'sslverify'=>false,'blocking'=>false,'body'=>get_permalink($post_id)));if(!is_wp_error($response)){$res=json_decode($response['body'],true);if($res['success_daily']==one)update_post_meta($post_id,'Fanly_Submit','OK');//OK Avoid repeated submission}}
Instructions for quick collection
1. Fast inclusion is only limited to submitting mobile end pages and mobile end adaptive pages.
2. The quick inclusion tool can actively push resources to Baidu Search, shorten the time for crawlers to find website links, and recommend the use of the quick inclusion tool for highly effective content to push resources to search in real time.
4. If the website has been verified as an HTTPS website by the HTTPS authentication tool, please ensure that the protocol header of the submitted link is HTTPS.
Statement:All articles on this site, unless otherwise specified or marked, are originally published on this site.No individual or organization is allowed to copy, embezzle, collect and publish the content of this website to any website, book and other media platforms without the consent of this website.If the content of this website infringes upon the legitimate rights and interests of the original author, please contact us for handling.