| 1 | // Example using HTTP POST operation |
| 2 | |
| 3 | "use strict"; |
| 4 | var page = require('webpage').create(), |
| 5 | server = 'http://posttestserver.com/post.php?dump', |
| 6 | data = '{"universe": "expanding", "answer": 42}'; |
| 7 | |
| 8 | var headers = { |
| 9 | "Content-Type": "application/json" |
| 10 | } |
| 11 | |
| 12 | page.open(server, 'post', data, headers, function (status) { |
| 13 | if (status !== 'success') { |
| 14 | console.log('Unable to post!'); |
| 15 | } else { |
| 16 | console.log(page.content); |
| 17 | } |
| 18 | phantom.exit(); |
| 19 | }); |