{"id":6258,"date":"2011-10-13T04:58:46","date_gmt":"2011-10-12T19:58:46","guid":{"rendered":"http:\/\/fukata.org\/?p=6258"},"modified":"2017-08-11T22:58:48","modified_gmt":"2017-08-11T22:58:48","slug":"nodejs-send-post-data-request-module","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6258\/","title":{"rendered":"node.js\u306erequest\u30e2\u30b8\u30e5\u30fc\u30eb\u304b\u3089POST\u3067\u30c7\u30fc\u30bf\u304c\u9001\u4fe1\u3067\u304d\u306a\u3044\u6642\u306e\u6ce8\u610f\u70b9"},"content":{"rendered":"

node.js\u306ehttpclient\u3068\u3057\u3066\u4f7f\u3044\u3084\u3059\u3044request\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u304c\u3001\u5c11\u3057\u30cf\u30de\u3063\u305f\u306e\u3067\u30e1\u30e2\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n

\u4f55\u3092\u3084\u308a\u305f\u3044\u304b\u3068\u3044\u3046\u3068\u3001\u5358\u7d14\u306bPOST\u3067\u3069\u3063\u304b\u306b\u30c7\u30fc\u30bf\u3092\u9001\u308a\u305f\u3044\u308f\u3051\u3067\u3059\u3002<\/p>\n

\u53d7\u3051\u53e3\u306f\u4eca\u56de\u306f\u30da\u30e9\u30a4\u30c1\u306ePHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n

\u6700\u521d\u3001\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n

\r\nvar request = require('request');\r\nrequest.post({\r\n  uri: 'https:\/\/localhost\/dump.php',\r\n  body: 'hoge=foo&aaa=bbb'\r\n});\r\n<\/pre>\n

\u305f\u3060\u3057\u3001PHP\u5074\u306e$_POST\u5909\u6570\u306b\u306f\u4e00\u5411\u306b\u5165\u308b\u6c17\u914d\u304c\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n

\u305d\u308c\u3092\u4e0b\u8a18\u306e\u3088\u3046\u306b\u9001\u4fe1\u30d8\u30c3\u30c0\u306econtent-type\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a\u3057\u3066\u3042\u3052\u308c\u3070\u6b63\u5e38\u306b\u53d7\u3051\u53d6\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3057\u305f\u3002<\/p>\n

\r\nvar request = require('request');\r\nrequest.post({\r\n  uri: 'https:\/\/localhost\/dump.php',\r\n  body: 'hoge=foo&aaa=bbb',\r\n  headers: {\r\n    'content-type': 'application\/x-www-form-urlencoded'\r\n  }\r\n});\r\n<\/pre>\n

\u3068\u308a\u3042\u3048\u305a\u3001\u7c21\u5358\u306b\u30e1\u30e2\u3002<\/p>\n

\u8ffd\u8a18\uff1a2011.11.13 12:38<\/strong>
\nPHP\u306e\u30bd\u30fc\u30b9\u3092\u76f4\u63a5\u898b\u305f\u3068\u3053\u308d\u3001POST\u306e\u5834\u5408\u3001\u4e0b\u8a18\u306e\u4e8c\u3064\u306econtent-type\u306e\u5834\u5408\u306e\u307f\u5909\u6570\u306b\u683c\u7d0d\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3057\u305f\u3002<\/p>\n