Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

javascript tweet status update

javascript tweet status update

Problem

Ok so I thought I would find the answer I was looking for with a search but maybe I'm just not understanding things, so here goes.

I want to run Status updates to my twitter account using javascript only my code runs on top of node.js so there is no html or php strictly javascript. So a text box is out php is out.

I've searched around and can't seem to find a solid example where I can just post using ajax or something to update my status can someone please point me in the right direction ?

Problem courtesy of: mcgrailm

Solution

Have a look at Mikeal's Request module. You can send a POST request as follows:

var request = require('request');
request.post({
  url: 'https://dev.twitter.com/docs/api/1/post/statuses/update',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    status: "Your new Twitter status"
  })
}, function(error, response, body){
  console.log(body);
});

Note that this example is not complete as you would still have to authenticate to Twitter.

Solution courtesy of: Phil Klein

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

javascript tweet status update

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×