summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/communication.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-11-17 16:45:04 +0000
committerRobert Pösel <robyer@seznam.cz>2014-11-17 16:45:04 +0000
commit6029781c4a2ca30552d96de331a640c653d8bfba (patch)
tree77564aefd40bb512fe295266d526d45c9b4cc239 /protocols/FacebookRM/src/communication.cpp
parent5507917da919d55aad972f8331a11da8f721f786 (diff)
Facebook: Use correct phstamp and ttstamp values in POST data (Facebook doesn't give a .... anyway)
git-svn-id: http://svn.miranda-ng.org/main/trunk@11005 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/communication.cpp')
-rw-r--r--protocols/FacebookRM/src/communication.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 3cefc8a822..053ed0c0e4 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -995,7 +995,15 @@ bool facebook_client::home()
}
this->dtsg_ = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""));
- parent->debugLogA(" Got self dtsg: %s", this->dtsg_.c_str());
+ {
+ // Compute csrf_ from dtsg_
+ std::stringstream csrf;
+ for (unsigned int i = 0; i < this->dtsg_.length(); i++) {
+ csrf << (int)this->dtsg_.at(i);
+ }
+ this->csrf_ = csrf.str();
+ }
+ parent->debugLogA(" Got self dtsg: %s (csrf: %s)", this->dtsg_.c_str(), this->csrf_.c_str());
if (this->dtsg_.empty()) {
parent->debugLogA("!!!!! Empty dtsg. Source code:\n%s", resp.data.c_str());
@@ -1219,7 +1227,7 @@ int facebook_client::send_message(MCONTACT hContact, std::string message_recipie
data += "&__user=" + this->self_.user_id;
data += "&__a=1";
data += "&fb_dtsg=" + this->dtsg_;
- data += "&phstamp=0";
+ data += "&phstamp=" + phstamp(data);
resp = flap(REQUEST_MESSAGE_SEND_INBOX, &data);
break;
@@ -1253,7 +1261,7 @@ int facebook_client::send_message(MCONTACT hContact, std::string message_recipie
data += "&fb_dtsg=" + this->dtsg_;
data += "&__user=" + this->self_.user_id;
data += "&__a=1";
- data += "&phstamp=0";
+ data += "&phstamp=" + phstamp(data);
resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
break;
@@ -1277,7 +1285,7 @@ int facebook_client::send_message(MCONTACT hContact, std::string message_recipie
data += "&message_batch[0][message_id]=";
data += "&fb_dtsg=" + this->dtsg_;
data += "&__user=" + this->self_.user_id;
- data += "&phstamp=0";
+ data += "&phstamp=" + phstamp(data);
resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
break;
@@ -1397,13 +1405,13 @@ bool facebook_client::post_status(status_data *status)
data = "fb_dtsg=" + this->dtsg_;
data += "&targetid=" + (status->user_id.empty() ? this->self_.user_id : status->user_id);
data += "&xhpc_targetid=" + (status->user_id.empty() ? this->self_.user_id : status->user_id);
- data += "&istimeline=1&composercontext=composer&onecolumn=1&nctr[_mod]=pagelet_timeline_recent&__a=1&ttstamp=0";
+ data += "&istimeline=1&composercontext=composer&onecolumn=1&nctr[_mod]=pagelet_timeline_recent&__a=1&ttstamp=" + ttstamp();
data += "&__user=" + (status->isPage && !status->user_id.empty() ? status->user_id : this->self_.user_id);
data += "&loaded_components[0]=maininput&loaded_components[1]=backdateicon&loaded_components[2]=withtaggericon&loaded_components[3]=cameraicon&loaded_components[4]=placetaggericon&loaded_components[5]=mainprivacywidget&loaded_components[6]=withtaggericon&loaded_components[7]=backdateicon&loaded_components[8]=placetaggericon&loaded_components[9]=cameraicon&loaded_components[10]=mainprivacywidget&loaded_components[11]=maininput&loaded_components[12]=explicitplaceinput&loaded_components[13]=hiddenplaceinput&loaded_components[14]=placenameinput&loaded_components[15]=hiddensessionid&loaded_components[16]=withtagger&loaded_components[17]=backdatepicker&loaded_components[18]=placetagger&loaded_components[19]=citysharericon";
http::response resp = flap(REQUEST_LINK_SCRAPER, &data, &status->url);
std::string temp = utils::text::html_entities_decode(utils::text::slashu_to_utf8(resp.data));
- data = "&xhpc_context=profile&xhpc_ismeta=1&xhpc_timeline=1&xhpc_composerid=u_jsonp_2_0&is_explicit_place=&composertags_place=&composer_session_id=&composertags_city=&disable_location_sharing=false&composer_predicted_city=&nctr[_mod]=pagelet_composer&__a=1&__dyn=&__req=1f&ttstamp=0";
+ data = "&xhpc_context=profile&xhpc_ismeta=1&xhpc_timeline=1&xhpc_composerid=u_jsonp_2_0&is_explicit_place=&composertags_place=&composer_session_id=&composertags_city=&disable_location_sharing=false&composer_predicted_city=&nctr[_mod]=pagelet_composer&__a=1&__dyn=&__req=1f&ttstamp=" + ttstamp();
std::string form = utils::text::source_get_value(&temp, 2, "<form", "</form>");
utils::text::replace_all(&form, "\\\"", "\"");
data += "&" + utils::text::source_get_form_data(&form) + "&";