Changeset 385428
- Timestamp:
- 05/16/2011 01:28:32 PM (15 years ago)
- File:
-
- 1 edited
-
qqpress/trunk/qqpress.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
qqpress/trunk/qqpress.php
r382174 r385428 5 5 Author URI: http://www.hencuo.com/ 6 6 Plugin URI: http://app.hencuo.com/qqpress 7 Description: 新文章发布时,将文章标题和URL发布到你的腾讯微博。 8 Version: 1. 27 Description: 新文章发布时,将文章标题和URL发布到你的腾讯微博。插件设置页面直接发微博。在日志中提到微博用户时,则通知这些用户。 8 Version: 1.3 9 9 */ 10 10 … … 157 157 //将日志同步到腾讯微博 158 158 function qqpress_publish($postID) { 159 $post = get_post( $postID);159 $post = get_post($postID); 160 160 161 161 //再次确认该日志状态为publish … … 163 163 $message = qqpress_get_message($postID); //格式化同步内容 164 164 qqpress_publish_2_qq($message); 165 166 //如果日志中有提到微博中用户,则发通知 167 preg_match_all("/@([A-Za-z]{1}[\w|-]*)[\s|,|。|?|,|.|?]/", $post->post_content, $matches); 168 if (2 == count($matches) && 0 < count($matches[1])) { 169 $oauth_token = get_option("qq_oauth_token"); 170 $oauth_token_secret = get_option("qq_oauth_token_secret"); 171 172 if(!$oauth_token || !$oauth_token_secret) 173 return; 174 175 if(!class_exists('MBOpenTOAuth')) 176 include dirname(__FILE__).'/opent.php'; 177 178 global $qq_consumer_key, $qq_consumer_secret; 179 $to = new MBOpenTOAuth($qq_consumer_key, $qq_consumer_secret, $oauth_token, $oauth_token_secret); 180 181 $params = array('format' => 'json', 'name' => ""); 182 $url = "http://open.t.qq.com/api/user/other_info?f=1"; 183 $users = array(); 184 foreach ($matches[1] as $username) { 185 $params["name"] = $username; 186 try { 187 $result = $to->get($url, $params); 188 if (false === array_search($username, $users)) 189 array_push($users, $result["data"]["name"]); 190 } catch (Exception $d) {} 191 } 192 if (0 < count($users)) { 193 $message = "我在新日志《" . $post->post_title . "》中提到了@" . implode(" @", $users) ." ". get_permalink($postID); 194 qqpress_publish_2_qq($message); 195 } 196 } 165 197 } 166 198 } 167 199 168 200 //将日志转换为自定义的同步格式 169 function qqpress_get_message($post ID) {201 function qqpress_get_message($post, $postID) { 170 202 $proto = get_option('qqpress_message'); 171 $post = get_post($postID);172 203 173 204 $proto = str_replace("[title]", $post->post_title, $proto);
Note: See TracChangeset
for help on using the changeset viewer.