How to send direct message using API V1.1?


#1

Hello all,
would you teach me how to send direct message useing API v1.1.
My App lebel is read, write and direct message.
It can use statuses/home_timeline, statuses/update, direct_messages, and etc.
but direct_messages/new can not. I get message_ HTTP/1.1 401 unauthorize.


#2

Can you provide an example of how you’re formulating the request? POSTing to direct_messages/new should be possible to any app with at least RW access. If you’re getting a 401 it’s likely due to OAuth signature validity.


#3

Hello episod,
Thanks for your reply.
I requested following:

URL: https://api.twitter.com/1.1/direct_messages/new.json
POST data:
screen_name=yama_1983
text=good%20morning
Request header:
Authorization: oauth oauth_consumer_key=“xxxxx”,oauth_nonce=“xxxxxxx”,oauth_signature_method="HMAC-SHA1,oauth_timestamp=“xxxxx”,oauth_token=“xmxxxxxx”,oauth_version="1.0"
Content-type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: xxx


#4

When you send your POST data, are your parameters separated by newlines or by the “&” character? They should be separated by the “&” character.


#5

I can send direct message.
Thanks for your advices.


#6

What will be the Request header and format? what is oauth_nonce, auth_timestamp and content-Length?