I'm using Twitter API and PHP to reply a specific tweet.
For example. If another user mentions me like "@Diga reply me!" I'm replying them. Otherwise, I just discard the mention.
This is a basic if statement and I could handle this. The problem is, when another user mentions me and I run the script again, scripts replies both of them because there is already another mention.
$statues = $connection->get("statuses/mentions_timeline");
if(count($statues)>0)
{
$message= strtolower($statues[0]->text);
$message= trim(str_replace("@diga","",$message));
if($message== "reply me!")
{
$user_name = "@".trim($statues[0]->user->screen_name);
$tweetID = $statues[0]->id_str;
$statues = $connection->post("statuses/update", ["status" => $user_name." I can reply you!", "in_reply_to_status_id" => $tweetID]);
}
}
else
{
echo "no mention.";
}
In this code, if there are any mentions, scripts starts checking the messages. Actually, I'm only checking one mention (0) because of testing. But still, I want to reply this tweet only 1 time. After that, even if I run this script, I don't want it to reply.