1

私はwp-twitterプラグイン(WordPress 3.0.1を使用)を使用して、投稿が作成されたときに自動的にツイートを作成しています。

コメントが作成されたときにツイートを作成する必要がありました...それを行うプラグインを知っていますか?

または、wp-twitterプラグインを変更した場合でも、ガイドラインを教えてください。

前もって感謝します!

4

1 に答える 1

3

comment_postフックアンドアドアクションを使用して、コンテンツを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);
于 2010-11-29T10:47:01.217 に答える