Node.js newbie

Events happening in the community are now at Drupal community events on www.drupal.org.
kscheirer's picture

I'm just getting started with node.js, and I'm hoping you guys can point e in the right direction.

I want to be able to log in to my Drupal site, what kind of add on do I need for this (if any). When using PHP's curl, you're able to post to a login form and then keep the cookie for future requests - which lets you interact with your site as an authenticated user.

Thanks in advance for any advice,
-ks

Comments

I think this might help, but

kscheirer's picture

I think this might help, but I could sure use some code examples! https://github.com/andris9/fetch

When you say you want to use

adammalone's picture

When you say you want to use node.js to log in to your Drupal site - how do you mean exactly?

Do you mean that node.js itself will be authenticated as a user?

What sort of purpose would this be for because there could potentially be an easier way.

I know most of the examples

kscheirer's picture

I know most of the examples for node.js are created server-side apps. I'm looking at it more as a client app - ie I want to be able to log into my Drupal site and do some actions as an authenticated user.

The logic would be something like :

  1. Issue a POST with username & password to /user/login form. This should send me back a authenticated session cookie.

  2. Make a second POST request (with the auth cookie) to /node/add/article to create a new article.

You might want to look into

mikey_p's picture

You might want to look into something like the request module which is an abstracted http client lib: https://npmjs.org/package/request.

Also, if you want something a little bit more full featured, you could look into phantomjs which is a full browser emulator: https://github.com/ariya/phantomjs/ (i.e. it should be able to store cookies automatically without any intervention).

Alternatively if it's posting

adammalone's picture

Alternatively if it's posting articles you could go the way of the blogapi module and use XMLRPC.

node.js

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: