summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-04-21 07:15:40 +0000
committerRobert Pösel <robyer@seznam.cz>2016-04-21 07:15:40 +0000
commita6bbe77262e2a28c664bdf3fa55cc1ab88761cf6 (patch)
treeb1706e2a0b1e96e278a9846589e1422fb73927ab /protocols
parent2384d4612f4d973ace00f3c231648c62661fb470 (diff)
Facebook: Fix loading own avatar for some rare circumstances
git-svn-id: http://svn.miranda-ng.org/main/trunk@16728 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/src/communication.cpp20
-rw-r--r--protocols/FacebookRM/src/constants.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 2878888130..5e7d249048 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -246,6 +246,7 @@ std::string facebook_client::choose_server(RequestType request_type)
case REQUEST_LOAD_FRIENDSHIPS:
case REQUEST_SEARCH:
case REQUEST_USER_INFO_MOBILE:
+ case REQUEST_PROFILE_PICTURE:
return this->mbasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE;
// case REQUEST_LOGOUT:
@@ -528,6 +529,11 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
return "/ajax/login/approvals/send_sms?dpr=1";
}
+ case REQUEST_PROFILE_PICTURE:
+ {
+ return "/profile/picture/view/?profile_id=" + self_.user_id;
+ }
+
default:
return "/?_fb_noscript=1";
}
@@ -1137,6 +1143,20 @@ bool facebook_client::home()
if (!this->self_.image_url.empty())
this->self_.image_url = "/" + this->self_.image_url;
}
+
+ // 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);
+
+ // 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", "<img src=\"", "\""));
+
+ // 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(&quot;", "&quot;)"));
+ }
+ }
parent->debugLogA(" Got self avatar: %s", this->self_.image_url.c_str());
parent->CheckAvatarChange(NULL, this->self_.image_url);
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 62d70c59ab..4516a26197 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -131,6 +131,7 @@ enum RequestType {
REQUEST_IDENTITY_SWITCH, // changing identity to post status for pages
REQUEST_CAPTCHA_REFRESH, // refreshing captcha dialog (changing captcha type)
REQUEST_LOGIN_SMS, // request to receive login code via SMS
+ REQUEST_PROFILE_PICTURE, // request mobile page containing profile picture
REQUEST_FEEDS, // getting feeds
REQUEST_NOTIFICATIONS, // getting notifications