Viral Solani
Viral Solani

Reputation: 840

Why i don't see my @replies in conversation view in twitter?

I need to reply to one particular twitter status. I'm using following functions. And I've used Abraham's twitteroauth library in php.

public function  replyToTwitterStatus($user_id,$status_id,$twitt_reply,$account_name)
{                       
       $connection= $this->getTwitterConnection($user_id,$account_name);                
        try{
           $responce = $this->postApiData('statuses/update', array('status' => $twitt_reply,'in_reply_to_status_id '=> $status_id),$connection);
        }
        catch(Exception $e){
            echo $message = $e->getMessage();
            exit;                  
        }             
}

// this function will handle all post requests
// To post/update twitter data

// To post/update twitter data

public function postApiData($request,$params = array(),$connection)
{         
    if($params == null)
    {
        $data = $connection->post($request);    
    }
    else
    {       

        $data = $connection->post($request,$params);
    }

    // Need to check the error code for post method      
    if($data->errors['0']->code == '88' || $data->errors['0']->message == 'Rate limit exceeded')
    {
        throw new Exception( 'Sorry for the inconvenience,Please wait for minimum 15 mins. You exceeded the rate limit');
    }
    else
    {
        return $data;
    }                  
}

But the issue is that it is not maintaining the conversation view and it is update like normal status for e.g @abraham hello how are you. but that "View conversation" is not coming. Like expanding menu is not coming.

Please do needful Thanks

Upvotes: 3

Views: 490

Answers (1)

James Holderness
James Holderness

Reputation: 23001

You've got an unwanted space in your in_reply_to_status_id key which causes that parameter to be ignored.

This call:

$responce = $this->postApiData('statuses/update', array(
  'status' => $twitt_reply,
  'in_reply_to_status_id ' => $status_id
), $connection);

should look like this:

$responce = $this->postApiData('statuses/update', array(
  'status' => $twitt_reply,
  'in_reply_to_status_id' => $status_id
), $connection);

Also, make sure that the $status_id variable is being handled as a string. Although they look like numbers, most ids will be too big to be represented as integers in php, so they'll end up being converted to floating point which isn't going to work.

Lastly, make sure you have include the username of the person you are replying to in the status text. Quoting from the documentation for the in_reply_to_status_id parameter:

Note:: This parameter will be ignored unless the author of the tweet this parameter references is mentioned within the status text. Therefore, you must include @username, where username is the author of the referenced tweet, within the update.

Upvotes: 1

Related Questions