I'm using the wp-twitter plugin (with WordPress 3.0.1) to automaticaly create tweets when a post is created and it's working great!
Now I needed to create tweets when a comment is created...do you know any plugin that does that?
Or even, if you had changed the wp-twitter plugin to do that, give me some guidelines please?
Thanks in advance!
You can use comment_post
hook and add action that will submit the content to your twitter account.
Example:
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);