diff options
author | aunsane <aunsane@gmail.com> | 2017-12-28 21:21:10 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-12-28 21:21:28 +0300 |
commit | 0156ed41dceeef48f070adf67f14d4ba4c4f6d61 (patch) | |
tree | d0e1dca4c2c9c3c056ae9cb69dde10ea59316481 /protocols/Steam/src/api/friend_list.h | |
parent | f0075f2b956969f29acd3bc9289c8a5f78faddad (diff) |
Steam: refactoring
- reworking http requests
- added ability to get game name by appid
- another attempt to fix #633
- minor refactoring
Diffstat (limited to 'protocols/Steam/src/api/friend_list.h')
-rw-r--r-- | protocols/Steam/src/api/friend_list.h | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/protocols/Steam/src/api/friend_list.h b/protocols/Steam/src/api/friend_list.h index b6ab98402b..604e797a2d 100644 --- a/protocols/Steam/src/api/friend_list.h +++ b/protocols/Steam/src/api/friend_list.h @@ -5,11 +5,12 @@ class GetFriendListRequest : public HttpRequest {
public:
GetFriendListRequest(const char *token, const char *steamId, const char *relationship = "friend,ignoredfriend,requestrecipient") :
- HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001")
+ HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001")
{
- AddParameter("access_token", token);
- AddParameter("steamid", steamId);
- AddParameter("relationship", relationship);
+ Uri
+ << CHAR_PARAM("access_token", token)
+ << CHAR_PARAM("steamid", steamId)
+ << CHAR_PARAM("relationship", relationship);
}
};
@@ -17,7 +18,7 @@ class AddFriendRequest : public HttpRequest {
public:
AddFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
- HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/AddFriendAjax")
+ HttpRequest(HttpPost, STEAM_WEB_URL "/actions/AddFriendAjax")
{
char login[MAX_PATH];
mir_snprintf(login, "%s||oauth:%s", steamId, token);
@@ -25,15 +26,11 @@ public: char cookie[MAX_PATH];
mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId);
- char data[128];
- mir_snprintf(data, _countof(data),
- "sessionID=%s&steamid=%s",
- sessionId,
- who);
+ Headers << CHAR_PARAM("Cookie", cookie);
- SetData(data, strlen(data));
- AddHeader("Cookie", cookie);
- AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ Content = new FormUrlEncodedContent(this)
+ << CHAR_PARAM("sessionID", sessionId)
+ << CHAR_PARAM("steamid", who);
}
};
@@ -41,7 +38,7 @@ class BlockFriendRequest : public HttpRequest {
public:
BlockFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
- HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/BlockUserAjax")
+ HttpRequest(HttpPost, STEAM_WEB_URL "/actions/BlockUserAjax")
{
char login[MAX_PATH];
mir_snprintf(login, "%s||oauth:%s", steamId, token);
@@ -49,15 +46,12 @@ public: char cookie[MAX_PATH];
mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId);
- char data[128];
- mir_snprintf(data, _countof(data),
- "sessionID=%s&action=ignore&steamid=%s",
- sessionId,
- who);
+ Headers << CHAR_PARAM("Cookie", cookie);
- SetData(data, strlen(data));
- AddHeader("Cookie", cookie);
- AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ Content = new FormUrlEncodedContent(this)
+ << CHAR_PARAM("sessionID", sessionId)
+ << CHAR_PARAM("steamid", who)
+ << CHAR_PARAM("action", "ignore");
}
};
@@ -65,7 +59,7 @@ class RemoveFriendRequest : public HttpRequest {
public:
RemoveFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) :
- HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/RemoveFriendAjax")
+ HttpRequest(HttpPost, STEAM_WEB_URL "/actions/RemoveFriendAjax")
{
char login[MAX_PATH];
mir_snprintf(login, "%s||oauth:%s", steamId, token);
@@ -73,15 +67,11 @@ public: char cookie[MAX_PATH];
mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId);
- char data[128];
- mir_snprintf(data, _countof(data),
- "sessionID=%s&steamid=%s",
- sessionId,
- who);
+ Headers << CHAR_PARAM("Cookie", cookie);
- SetData(data, strlen(data));
- AddHeader("Cookie", cookie);
- AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
+ Content = new FormUrlEncodedContent(this)
+ << CHAR_PARAM("sessionID", sessionId)
+ << CHAR_PARAM("steamid", who);
}
};
|