ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` function _baidu_tuisong($post_ID) { global $post; if(function_exists('curl_init') ) { //判断下是否开启了 curl 扩展 $_tuisong_site = '再次输入你的域名,比如.me,不带 http://的'; $_tuisong_token = '在此输入你的密钥'; if( empty($post_ID) || empty($_tuisong_site) || empty($_tuisong_token) ) return; $api = 'http://data.zz.baidu.com/urls?site='.$_tuisong_site.'&token='.$_tuisong_token; //百度官方的 api if( $post->post_status = "publish" ) { //仅限已发布的文章 $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); ```