From bd21671c5fea36e9deb7ebf7f255116c67439b14 Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Mon, 8 Sep 2014 08:22:38 +0000 Subject: VKontakte: upgrade vk api version to 5.24 - users.get, frends.get git-svn-id: http://svn.miranda-ng.org/main/trunk@10406 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/vk_thread.cpp | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'protocols/VKontakte/src/vk_thread.cpp') diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 4d6a19d458..2b4b1ff4d3 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -201,7 +201,8 @@ LBL_NoForm: void CVkProto::RetrieveMyInfo() { // Old method - Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/getUserInfoEx.json", true, &CVkProto::OnReceiveMyInfo)); + Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnReceiveMyInfo) + << VER_API); } void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) @@ -216,16 +217,10 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) return; - - for (size_t i = 0; i < json_size(pResponse); i++) { - JSONNODE *it = json_at(pResponse, i); - LPCSTR id = json_name(it); - if (!_stricmp(id, "user_id")) { - m_myUserId = json_as_int(it); - setDword("ID", m_myUserId); - } - } - + + m_myUserId = json_as_int(json_get(json_at(pResponse, 0), "id")); + setDword("ID", m_myUserId); + OnLoggedIn(); RetrieveUserInfo(m_myUserId); RetrieveFriends(); @@ -237,10 +232,11 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) void CVkProto::RetrieveUserInfo(LONG userID) { - // Old method - // replaced to users.get - Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/getProfiles.json", true, &CVkProto::OnReceiveUserInfo) - << INT_PARAM("uids", userID) << CHAR_PARAM("fields", "uid,first_name,last_name,photo_medium,sex,bdate,city,relation")); + Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/users.get.json", true, &CVkProto::OnReceiveUserInfo) + << INT_PARAM("user_ids", userID) + << CHAR_PARAM("fields", "id, first_name, last_name, photo_100, sex, country, timezone, contacts, online") + << CHAR_PARAM("name_case", "nom") + << VER_API); } void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) @@ -256,9 +252,10 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe for (size_t i=0; ; i++) { JSONNODE *pRecord = json_at(pResponse, i); - if (pRecord == NULL) break; + if (pRecord == NULL) + break; - LONG userid = json_as_int( json_get(pRecord, "uid")); + LONG userid = json_as_int( json_get(pRecord, "id")); if (userid == 0) return; @@ -295,8 +292,10 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe } } - szValue = json_as_string( json_get(pRecord, "photo_medium")); + szValue = json_as_string( json_get(pRecord, "photo_100")); SetAvatarUrl(hContact, szValue); + + setWord(hContact, "Status", (json_as_int(json_get(pRecord, "online")) == 0) ? ID_STATUS_OFFLINE : ID_STATUS_ONLINE); } } @@ -308,7 +307,9 @@ void CVkProto::RetrieveFriends() // Old method // fields 'country' and 'city' replaced to objects Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/friends.get.json", true, &CVkProto::OnReceiveFriends) - << INT_PARAM("count", 1000) << CHAR_PARAM("fields", "uid,first_name,last_name,photo_medium,sex,country,timezone,contacts")); + << INT_PARAM("count", 1000) + << CHAR_PARAM("fields", "id, first_name, last_name, photo_100, sex, country, timezone, contacts, online") + <