Saturday 6 May 2017

Sending POST request to a Drupal module file

I'm trying to send a post request to a Drupal .module file from node.js. My problem is that the module file is never executed as php by Apache when the request is made, so instead of getting a response from php, I get the literal code (inside the .module file) as a text string.

I tried enabling .module to execute as php (not sure the security implications) by putting the following in .htaccess:

Addhandler application/x-httpd-php .module

(and virtually every other combination of that command I could find)

But no luck.

I know the post request sent by node.js is perfectly fine because it works when sent to .php files on the same server. I just can't get it to work within a Drupal module. I want it to be sent to a Drupal module because I want to take advantage of Drupal's API (going to be doing a lot of modifications to drupal user tables).

How do I send a post request to a drupal module, programmatically, from node and read its response? I know how to send it to a simple .php file, but not to a drupal module.



via Chris Scott

No comments:

Post a Comment