mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-28 13:20:23 +08:00
Added _myProfile helper to make calls to the user's profile URL
This commit is contained in:
parent
7f2a287c56
commit
0cb5eef1f8
18
index.js
18
index.js
@ -130,4 +130,22 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
||||
return false;
|
||||
};
|
||||
|
||||
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
|
||||
var self = this;
|
||||
this._request("https://steamcommunity.com/my", {"followRedirect": false}, function(err, response, body) {
|
||||
if(err || response.statusCode != 302) {
|
||||
callback(err || "HTTP error " + response.statusCode);
|
||||
return;
|
||||
}
|
||||
|
||||
var match = response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/);
|
||||
if(!match) {
|
||||
callback("Can't get profile URL");
|
||||
return;
|
||||
}
|
||||
|
||||
(form ? self._request.post : self._request)("https://steamcommunity.com" + match[1] + "/" + endpoint, form ? {"form": form} : {}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
require('./classes/CSteamGroup.js');
|
||||
|
Loading…
Reference in New Issue
Block a user