Guest User

Untitled

a guest
Jan 17th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. app.get('/subscribe-twitter-webhooks', (req, res) => {
  2. // twitter authentication
  3. var twitter_oauth = {
  4. consumer_key: 'CONSUMER_KEY',
  5. consumer_secret: 'CONSUMER_SECRET',
  6. token: 'ACCESS_TOKEN',
  7. token_secret: 'TOKEN_SECRET'
  8. };
  9.  
  10. var WEBHOOK_URL = 'https://api.mydomain.com/twitter/webhooks';
  11.  
  12. // request options
  13. var request_options = {
  14. url: 'https://api.twitter.com/1.1/account_activity/webhooks.json',
  15. oauth: twitter_oauth,
  16. headers: {
  17. 'Content-type': 'application/x-www-form-urlencoded'
  18. },
  19. form: {
  20. url: WEBHOOK_URL
  21. }
  22. }
  23. // POST request to create webhook config
  24. request.post(request_options, function (error, response, body) {
  25. console.log('--er--', error)
  26. console.log('--body--', body)
  27. });
  28. });
Add Comment
Please, Sign In to add comment