TalkAdmin: use WeChat voice to publish WordPress articles

» WordPress » TalkAdmin: use WeChat voice to publish WordPress articles

A few days ago, I shared a function of using WeChat to subscribe to my own website, which is through the official account of Sugar Balloon. Now I always share a method of using WeChat voice to control your website.

TalkAdmin:使用微信语音来发布WordPress文章-极客公园

preface

introduce

TalkAmin is a WeChat voice command tool launched by Fangtang Balloon. Just input the voice, match the corresponding regularity and provide the interface link. One is the uplink command, and the other is the downlink command. In short, the uplink command is that we use WeChat to send a command to the website, while the downlink command is that the website sends a command to WeChat, and then returns a command. A typical downlink command is the website comment review function. Of course, what we are talking about today is not the downward command but the upward command. The playing method of downward command will be written in a few days.

use

Although my evil title is to publish articles for WordPress, because an article is too long, it is unlikely to be solved with voice at one time, so we can use a relatively short text. My website has a function of saying that the basic words used are very short, So we are going to use the uplink command of the sugar balloon to achieve the function of voice messaging on WeChat. Since my talk is a custom post type, it is OK to use the function of inserting an article.

code

Save the following code as a file, put it in the secondary directory of the website, and just save a name you know.

 <? php if( ! isset( $_GET['pk'] ) && $_GET['pk'] != ' 8899 ') exit ('parameter error'); define('WP_DEBUG', false); define('WP_USE_THEMES', false); require('../ wp-blog-header.php'); $wxtalk = stripslashes($_POST['json']); //  Accept request parameters $str = json_decode($wxtalk,true)[1][0]; $res=str_replace (['comma ',' period ',' question mark ',' exclamation mark '], [', ','. ','? ','! '], $str); $my_post = array( 'post_title'    => wp_strip_all_tags($res), 'post_content'  => wp_strip_all_tags($res), 'post_status'   => 'publish', 'post_type'=>'shuoshuo',//Customize the article type 'post_author'=>1//User ID ); $talkres = wp_insert_post( $my_post ); if(! empty($talkres)){ echo 'success'; }else{ echo 'fail'; } ?>

Configure Use

The above code is written and placed in a secondary directory, any directory
TalkAdmin:使用微信语音来发布WordPress文章-极客公园

TalkAdmin:使用微信语音来发布WordPress文章-极客公园

In the above figure, only three names are filled in. If the names are regular, all the names should match /(.+)/ , select the uplink command, and the Webhook address will fill in the link of the PHP file above, followed by the? Pk=8899 [8899 needs to be consistent with the code]
  • Now, try sending voice directly to the service number of the sugar balloon

--End--

Post reply

Your email address will not be disclosed. Required items have been used * tagging

3 Replies to "TalkAdmin: use WeChat voice to publish WordPress articles"