wordpress微博同步插件
- <?php
- /*
- Plugin Name: WP-Weibo
- Plugin URI: http://blog.peos.cn
- Description: Wordpress 分享到微博
- Version: 1.0
- Author: 数据库之家
- Author URI: http://blog.peos.cn
- License: GPL2
- */
- function post_to_sina_weibo($post_ID)
- {
- if (wp_is_post_revision($post_ID)) return;//修订版本(更新)不发微博
- //$get_post_info = get_post($post_ID);
- //$get_post_centent = get_post($post_ID)->post_content;
- $get_post_title = get_post($post_ID)->post_title;
- if ($get_post_info->post_status == 'publish' )
- {
- $appkey='******';
- $username='liangdianbaike@163.com';
- $userpassword='******';
- $request = new WP_Http;
- $status = strip_tags($get_post_title) . ' - 百度云 百度网盘 百度云网盘下载' . get_permalink($post_ID);
- $api_url = 'https://api.weibo.com/2/statuses/update.json';
- $body = array('status' => $status,'source' => $appkey);
- $headers = array('Authorization' => 'Basic ' . base64_encode("$username:$userpassword"));
- $result = $request->post($api_url, array('body' => $body,'headers' => $headers));
- }
- }
- //给发布文章增加一个分享微博的动作
- add_action('publish_post', 'post_to_sina_weibo', 0);
- ?>
============ 欢迎各位老板打赏~ ===========
与本文相关的文章
- · wordpress更新需要的目录权限
- · 群晖web station设置wordpress 伪静态
- · 人像磨皮滤镜插件portraiture破解版.zip
- · 群晖NAS使用webstation搭建wordpress 问题汇总
- · wordpress集成markdown
- · free:10分钟把你的WordPress网站改成HTTPS
- · 升级PHP7后,wordpress报错,页面显示不全
- · Linux升级PHP5.x至PHP7.2.0
- · WordPress优化加速服务
- · 禁止wordpress加载google字体 WordPress禁用Open Sans
- · add_rewrite_rule用法
- · wordpress使用百度的JQUERY公共库