puritys / nodejs-phplike

Porting PHP to Node.js
http://www.puritys.me/docs-blog/article-201
33 stars 12 forks source link

Curl is not working in Centos 6 #7

Closed fahidmohammad closed 7 years ago

fahidmohammad commented 7 years ago

OS

Linux hoPla-batch 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Nodejs Version

v7.8.0

ERROR

root\public\Folder\Folder\node_modules\phplike\src\js\curl.js:183
    var response =  cpp.request(method, url, param, header, options, fileUpload);
                       ^

TypeError: Cannot read property 'request' of undefined
    at Object.exports.request (root\public\Folder\Folder\node_modules\phplike\src\js\curl.js:183:24)
    at Object.exports.curl_exec (root\public\Folder\Folder\node_modules\phplike\src\js\curl.js:163:25)
    at Object.<anonymous> (root\public\Folder\Folder\Search.js:104:16)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:425:7)

Setup was smooth but when i execute the Curl request i got the above error.

Sample Request


      var php = require("phplike/module.js");
    var url = "https://xxxx.xxx.com.eg:0000/xmlgw/merchant";
    var params = {}; // Send parameter
    var header = {}; // Send cookie 
    var c = php.curl_init();
    php.curl_setopt(c, 'CURLOPT_URL', url);
    php.curl_setopt(c, 'CURLOPT_POST', 1);
    php.curl_setopt(c, 'CURLOPT_POSTFIELDS', "a=bbb&c=eee");
    php.curl_setopt(c, 'CURLOPT_HTTPHEADER', header);
    var res = php.curl_exec(c);
    var responseHeader = php.getResponseHeader();
puritys commented 7 years ago

Thanks your report, I will check this issue soon.

puritys commented 7 years ago

Hi @fahidmohammad, Could you try phplike@2.5.4 to see the new version will fix it or not.