How to reply to a tweet from the API


Looking through the API I did not see a way to reply to a tweet from another user. Can anyone point me in the correct direction? I have the url to the Tweet from GET statuses/user_timeline and would like to reply to the tweet using an API.



You need to use the statuses/update endpoint and the in_reply_to_status_id parameter, passing in the ID of the Tweet you want to post a reply to.


Thanks for the response so would the post look like this,


where 123456789 is the ID of the tweet I want to reply to. Sorry for the dumb question but I have not used a post with two parameters as of yet. I am not sure what to separate the parameters with in the above I used a colon.



URL parameters are separated with &.


Thanks for the info.

When I add the


parameter to the status update I get Response Text: {“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]} error.

Could this be an enterprise feature that require additional authentication?


This is not an enterprise feature, it is completely standard. You do need to have valid consumer key/token and access token/secret, and to calculate the OAuth signature correctly. Can you share a code snippet?


This is a Excel VB application the actual sending of the command is done by this

Dim objRest As WinHttp.WinHttpRequest
Set objRest = New WinHttp.WinHttpRequest
objRest.Open "POST", "", False
objRest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objRest.setRequestHeader "Authorization", strHeader
objRest.Send "status=" & "TextofTweet"

Which works fine and the tweet is sent, I know my key/token and access token/secret, are valid.
However If I change the objRest.Send command to
objRest.Send “status=” & “TextofTweet” & “&in_reply_to_status_id=989204711994781696”
it fails with the authorization error I mentioned, Response Text: {“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}.

the Authorization header above , strHeader is generated by the following,

'create basestring
tmpBase = “oauth_consumer_key=” & cnsOauthConsumerKey
tmpBase = tmpBase & “&” & “oauth_nonce=” & strNonce
tmpBase = tmpBase & “&” & “oauth_signature_method=” & cnsMethod
tmpBase = tmpBase & “&” & “oauth_timestamp=” & strTimestamp
tmpBase = tmpBase & “&” & “oauth_token=” & cnsOauthToken
tmpBase = tmpBase & “&” & “oauth_version=” & cnsOauthVersion
tmpBase = tmpBase & “&” & “status=” & strStatus
tmpBase = tmpBase & “&” & “in_reply_to_status_id=989204711994781696” (Again if I add this line it fails)

basestring = cnsAPIMethodP & “&” & UrlEncode((cnsURLPost)) & “&” & UrlEncode(tmpBase)

Then from the base string to generating the the Authorization header everything is the same. With the above snippets can you see anything wrong? The rest of the code is the same and works if I do not make the two changes above adding the “&in_reply_to_status_id=989204711994781696”
Thanks for the help,


Are you able to send a tweet using twurl or any other standard library?
I would use twurl to look at the headers it is sending to twitter and make sure you’re doing the same.


I have not attempted to use an alternate method to send the Tweet.
I presume my approach and understanding of the API as stated above is correct. So I guess it must be something in the code, and the next step would be to verify what is being sent. Thanks and I will keep you posted.


It is not recommend to build your own OAuth encoding process. It’s very complex and is easy to get wrong. I suspect the error is because you are not sorting the parameters.

  1. Sort the list of parameters alphabetically by encoded key.


Have you considered using your Excel FB file that outputs its unique contribution then maybe using twurl in a bash script to send the tweets? Anything to avoid reinventing the oAuth wheel.


“abraham” nailed it – you are correct I had to Sort the parameters in alphabetically order by encoded key, just so happened I added the parameter in_reply_to_status_id which goes to the top of the list ahead of the oauth_* parameters. Sorted the list correctly and it works perfectly. I agree rolling your own code to do the OAuth encoding process is a head ace. I will look into the other suggestions offered by bobbe205 and andypiper. Thank you all for the help, I am very impressed with your knowledge and the support you all provided. Thanks again.

closed #16