diff options
| -rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 20 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/constants.h | 1 | 
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("", "")")); +			} +		}  		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
  | 
