Skip to content

Instantly share code, notes, and snippets.

@dscape
Forked from supafoundation/gist:1838937
Created February 15, 2012 20:56
Show Gist options
  • Save dscape/1838953 to your computer and use it in GitHub Desktop.
Save dscape/1838953 to your computer and use it in GitHub Desktop.
var url_parts = url.parse(req.url, true);
var query1 = url_parts.query;
// Build the post string from an object
var query=querystring.stringify(query1);
var post_options = {
host: 'steamcommunity.com',
port: '443',
path: '/openid/login?',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(query)
}
};
var post_req = http.request(post_options, function(res) {
res.setEncoding('utf-8');
var fullBody = '';
res.on('data', function (chunk) {
fullBody += chunk.toString();
});
res.on('end', function() {
var pattern=/is_valid:true/g;
var result = pattern.test(fullBody);
// i need the result of this to be
}
});
});
post_req.write(query);
post_req.end();
//HERE
res.end();
var request = require('request')
, qs = require('querystring')
;
var user = {username: "cl0udy"}
, post =
{ method: 'POST'
, url : 'https://steamcommunity.com/openid/login?' + qs.stringify(user)
// , body : qs.stringify(user)
}
;
request(post, function(err,response,body) {
console.log(response.statusCode, body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment