From 9fb06fd3a3c18d3e27f68be92c7eab599cea8a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Thu, 21 Apr 2016 07:15:50 +0000 Subject: Facebook: Workaround for missing own avatar on some very rare occasions Sometimes even Facebook doesn't show any picture at all! git-svn-id: http://svn.miranda-ng.org/main/trunk@16732 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/communication.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 5e7d249048..8e77b71316 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1146,15 +1146,21 @@ bool facebook_client::home() // Final attempt to get avatar as on some pages is only link to photo page and not link to image itself if (this->self_.image_url.empty()) { - if (resp.data.find("/profile/picture/view/?profile_id=") != std::string::npos) { - http::response resp2 = flap(REQUEST_PROFILE_PICTURE); + http::response resp2 = flap(REQUEST_PROFILE_PICTURE); - // Get avatar (from mbasic version of photo page) - this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "self_.image_url.empty()) - this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "background-image: url("", "")")); + // Get avatar (from touch version) + if (this->self_.image_url.empty()) + this->self_.image_url = utils::text::html_entities_decode(utils::text::source_get_value(&resp2.data, 3, "id=\"root", "background-image: url("", "")")); + + // Sometimes even Facebook doesn't show any picture at all! So just ignore this error in that case... + if (this->self_.image_url.empty()) { + parent->debugLogA("!!! Empty avatar even from avatar page. Source code:\n%s", resp2.data.c_str()); + + // Set dumb avatar "url" (see how it works in CheckAvatarChange()) so we can't tell if/when the avatar changed, but it will be loaded at least once + this->self_.image_url = "/NO_AVATAR/"; } } -- cgit v1.2.3