Skip to content

Conversation

@JulienSol
Copy link

@JulienSol JulienSol commented Jun 3, 2017

Some Twitter API POST requests need a JSON POST body. (Like the new direct_messages endpoint)
As node-twitter constrain us to use form or form-data POST method, we aren't able to use new Twitter functionalities.

This commit adds a post_method option in node-twitter's options which is, when modified in order to follow request options, used to pass POST data.

This also solves different others pull request : #220 #167

@desmondmorris
Copy link
Owner

@JulienSol thanks for this. If I wanted to execute a few POST requests in success where each is a different post_method types, would I need a separate client instance? See: #167 (comment).

@JulienSol
Copy link
Author

No, you just need to modify the option with:

twitter.options.post_method = 'form';

@dfliess
Copy link

dfliess commented Sep 29, 2017

Hi It's working if i use:

twitter.options.post_method = 'json';

but I'm receiving an Error although the message is sent. i've tried with form and formData without success.

Error: JSON parseError with HTTP Status: 200 OK
     at Request._callback (<proyect_folder>/node_modules/twitter/lib/twitter.js:200:9)
     at Request.self.callback (<proyect_folder>/node_modules/request/request.js:186:22)
     at emitTwo (events.js:106:13)
     at Request.emit (events.js:191:7)
     at Request.<anonymous> (<proyect_folder>/node_modules/request/request.js:1060:10)
     at emitOne (events.js:96:13)
     at Request.emit (events.js:188:7)
     at IncomingMessage.<anonymous> (<proyect_folder>/node_modules/request/request.js:980:12)
     at IncomingMessage.g (events.js:291:16)
     at emitNone (events.js:91:20)
     at IncomingMessage.emit (events.js:185:7)
     at endReadableNT (_stream_readable.js:974:12)
     at _combinedTickCallback (internal/process/next_tick.js:74:11)
     at process._tickDomainCallback (internal/process/next_tick.js:122:9)

@teifip
Copy link

teifip commented Jan 9, 2018

@desmondmorris and @JulienSol
I have just created pull request #278 to propose a slightly different approach.
Please consider that I'm new to the use of this library, and not familiar with the maintenance routines you have in place. Accept my apologies if you would have preferred my proposal to come in a different form than a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants