Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a page.post function #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

RaphaelRheault
Copy link

I needed to access a page using the post action for authentication, so I added a page.post function that calls Phantom's open(url,'post',data,callback). I thought I could share it in case someone else needs it.

Definition :
page.post(url, data[, callback])
url : where to post
data : html encoded string with the body of the request
callback : callback function (optional)

Example code :
var phantom=require('node-phantom');
phantom.create(function(error,ph){
ph.createPage(function(err,page){
var data = "email=test@domain.com&pass=my_pass";
page.post('http://domain.com/login',data,function(err,status){
//Do stuff here
});
});
});

Added page.post function to allow a render through a post action.

page.post(url, data[, callback])
	url : where to post
	data : html encoded string with the body of the request 
	callback : callback function (optional)

Example :
var phantom=require('node-phantom');
phantom.create(function(error,ph){
	ph.createPage(function(err,page){
		var data = "email=test@domain.com&pass=my_pass";
		page.post('http://domain.com/login',data,
		function(err,status){
			//Do stuff here
		});
	});
});
Added two cases : pagePost and pagePostWithCallback
Both of them calls Phantom's open(url,'post',data,callback)
Function to test the page.post function.
Actually, it's only a copy of testpageopen.js that calls page.post instead.
@hallas
Copy link

hallas commented Nov 15, 2013

I need this badly. 👍

@michaelklem
Copy link

Need this.

@zhouseahe
Copy link

ph.createPage(function(err,page){
// why does my application stop here , no error reported . what should I do , thanks

@starsinmypockets
Copy link

++please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants