views:

389

answers:

1

Hi i am trying to make a twitter application. I have gotten my application to a point where users log in through Twitter's user verification system. I am also able to send status updates using my application. I have this function to send status updates:

[CODE]

function sendTweet($tx){

 $consumer_key = 'MY CONSUMER KEY';
 $consumer_secret = 'MY CONSUMER SECRET';

 $Twitter = new EpiTwitter($consumer_key, $consumer_secret);
 $Twitter->setToken($_SESSION['OT'],$_SESSION['OTS']);

 $text=$tx;
 $status=$Twitter->post_statusesUpdate(array('status' => $text));
 $status->response;

}

[/CODE] This sendTweet($tx) function works like a charm but now what i need to do is get a list of followers of a user and then send Direct Messages to them. How can I do this using oauth and PHP?

A: 

function sendDirectMessage($user,$message) { $consumer_key = 'YOUR CONSUMER KEY'; $consumer_secret = 'YOUR SECRET';

 $Twitter = new EpiTwitter($consumer_key, $consumer_secret);
 $Twitter->setToken($_SESSION['OT'],$_SESSION['OTS']);

 $myArray = array('user' => $user, 'text' => $message);

 $resp = $Twitter->post_direct_messagesNew( $myArray);
 $resp->response;
}
Munish Kumar