使用wordpress创建评论时发出Tweet

使用wordpress创建评论时发出Tweet,wordpress,twitter,tweets,Wordpress,Twitter,Tweets,我正在使用wp推特插件(WordPress 3.0.1)在创建帖子时自动创建推特,效果非常好 现在我需要在创建评论时创建tweet…你知道有什么插件可以做到这一点吗 或者,如果你改变了wp-twitter插件,请给我一些指导 提前谢谢 您可以使用钩子和添加操作将内容提交到您的twitter帐户 例如: function tweet_comment($comment_ID, $approved) { if($approved) { $comment = get_comment($

我正在使用wp推特插件(WordPress 3.0.1)在创建帖子时自动创建推特,效果非常好

现在我需要在创建评论时创建tweet…你知道有什么插件可以做到这一点吗

或者,如果你改变了wp-twitter插件,请给我一些指导

提前谢谢

您可以使用钩子和添加操作将内容提交到您的twitter帐户

例如:

function tweet_comment($comment_ID, $approved) {
   if($approved) {
      $comment = get_comment($comment_ID);
      //Submit to twitter => $comment->comment_content
      $consumerKey = '<insert your consumer key';
      $consumerSecret = '<insert your consumer secret>';
      $oAuthToken = '<insert your access token>';
      $oAuthSecret = '<insert your token secret>';

      require_once('<insert_path_to_twitteroauth>/twitteroauth.php');

      // create a new instance
      $tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);

      //send a tweet
      $tweet->post('statuses/update', array('status' => substr($comment->comment_content, 0, 140)));
   }
}
add_action('comment_post','tweet_comment', 10, 2);
函数tweet\u comment($comment\u ID,$approved){
若有($核准){
$comment=get\u comment($comment\u ID);
//提交到twitter=>$comment->comment\u内容
$consumerKey='1〕