Piroro-hs / react-native-twitter

A Twitter API client library for React Native. Currently not maintained as my main motivation of creating this library was to use the User Streams API.
MIT License
39 stars 20 forks source link

unable to send direct message #22

Open marymhart opened 5 years ago

marymhart commented 5 years ago

Hello, I am unable to send a direct message. I have the direct message permission enabled in the developer console & the recipient has direct messages enabled from any user. The error I receive is not much help so any insight would be appreciated. Thank you! I am using: "react": "16.4.1", "react-native": "0.56.0", "react-native-twitter": "^0.2.1",

error: err Error at request.js:60 at tryCatch (es6-promise.js:409) at invokeCallback (es6-promise.js:424) at es6-promise.js:176 at MessagePort.flush (es6-promise.js:128)

code:


  const data = {
       "event": {
      "type": "message_create",
      "message_create": {
        "target": {
          "recipient_id": TWITTER_USER_ID_STR
        },
        "message_data": {
          "text": "Hi",
        }
      }
    }
  };

const parsedTokens = (JSON.parse(tokens));
        const { rest } = twitter(parsedTokens);
        rest.post('direct_messages/events/new', data ).then((resp) => {
          console.log('resp', resp);
          dispatch(updateProfileLoading(false));
        }).catch((err) => {
          console.log('err', err);
          dispatch(updateProfileLoading(false));
        });```