Hi all. I am trying to write a script that will send a message to new followers using POST direct_messages/new. My account access level is read,write and direct messages but I am getting “Your credentials do not allow access to this resource” with code:220. I am not sure why this is. Am I missing something?

1 Like

I have the same problem too :frowning: can’t find why

1 Like

solution go to twitter dev admin
create “Access token:” and “Access token secret:”

if you try to send message without these 2 things it’s not working.

:wink: good luck

Albert

1 Like

Do you have an example code how you use those in the POST header? I thought it’d be enough to use the Bearer token, but I think I’m wrong.

You can’t use a bearer token to send DMs, because the bearer token is only used to perform requests on behalf of an application itself, not a user using that application (so there is no account to send the DM from). Access tokens are used for authenticating requests on behalf of users.

It’s a lot easier to let a library take care of sorting out the headers unless you have a very specific use case - what language are you using?

2 Likes