From 6dd71dba3863c45c72d9c3bfd408f969bbb33a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Sun, 22 Jan 2017 22:31:24 +0100 Subject: Facebook: Fix searching (by name/email/...) --- protocols/FacebookRM/src/process.cpp | 9 +++++++-- protocols/FacebookRM/src/requests/search.h | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'protocols/FacebookRM') diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 600dc5a952..6b1d126a7e 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -1212,15 +1212,16 @@ void FacebookProto::SearchAckThread(void *targ) std::string search = utils::url::encode(T2Utf((wchar_t *)targ).str()); std::string ssid; + int pn = 1; while (count < 50 && !isOffline()) { - SearchRequest *request = new SearchRequest(facy.mbasicWorks, search.c_str(), count, ssid.c_str()); + SearchRequest *request = new SearchRequest(facy.mbasicWorks, search.c_str(), count, pn, ssid.c_str()); http::response resp = facy.sendRequest(request); if (resp.code == HTTP_CODE_OK) { - std::string items = utils::text::source_get_value(&resp.data, 4, ""); + std::string items = utils::text::source_get_value(&resp.data, 4, ""); std::string::size_type pos = 0; std::string::size_type pos2 = 0; @@ -1270,9 +1271,13 @@ void FacebookProto::SearchAckThread(void *targ) } ssid = utils::text::source_get_value(&items, 3, "id=\"more_objects\"", "ssid=", "&"); + pn++; // increment page number if (ssid.empty()) break; // No more results } + else { + break; + } } ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0); diff --git a/protocols/FacebookRM/src/requests/search.h b/protocols/FacebookRM/src/requests/search.h index ccef176818..127a559dba 100644 --- a/protocols/FacebookRM/src/requests/search.h +++ b/protocols/FacebookRM/src/requests/search.h @@ -3,7 +3,7 @@ Facebook plugin for Miranda Instant Messenger _____________________________________________ -Copyright © 2011-17 Robert Pösel +Copyright � 2011-17 Robert P�sel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,15 +27,15 @@ along with this program. If not, see . class SearchRequest : public HttpRequest { public: - SearchRequest(bool mobileBasicWorks, const char *query, int s, const char *ssid) : - HttpRequest(REQUEST_GET, FORMAT, "%s/search/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE) + SearchRequest(bool mobileBasicWorks, const char *query, int s, int pn, const char *ssid) : + HttpRequest(REQUEST_GET, FORMAT, "%s/search/people/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE) { flags |= NLHRF_REDIRECT; Url - << "search=people" - << CHAR_VALUE("query", query) - << INT_VALUE("s", s); + << CHAR_VALUE("q", query) + << INT_VALUE("s", s) + << INT_VALUE("pn", pn); if (mir_strlen(ssid) > 0) { Url << CHAR_VALUE("ssid", ssid); -- cgit v1.2.3