summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/requests
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-09-04 14:04:49 +0000
committerRobert Pösel <robyer@seznam.cz>2016-09-04 14:04:49 +0000
commit8234832e06e873df035270f162d7d151fbf6e7eb (patch)
tree200613059ddb4bc61c73fa946ca735836ee92163 /protocols/FacebookRM/src/requests
parent2f492f0c3af53dada6b909d1c31dc665c33dfde5 (diff)
Facebook: Massive rewrite of all communication requests
Note it doesn't use persistent connection yet. git-svn-id: http://svn.miranda-ng.org/main/trunk@17246 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/requests')
-rw-r--r--protocols/FacebookRM/src/requests/channel.h101
-rw-r--r--protocols/FacebookRM/src/requests/contacts.h191
-rw-r--r--protocols/FacebookRM/src/requests/feeds.h60
-rw-r--r--protocols/FacebookRM/src/requests/history.h167
-rw-r--r--protocols/FacebookRM/src/requests/login.h116
-rw-r--r--protocols/FacebookRM/src/requests/messages.h161
-rw-r--r--protocols/FacebookRM/src/requests/notifications.h75
-rw-r--r--protocols/FacebookRM/src/requests/profile.h83
-rw-r--r--protocols/FacebookRM/src/requests/search.h46
-rw-r--r--protocols/FacebookRM/src/requests/status.h74
-rw-r--r--protocols/FacebookRM/src/requests/utils.h195
11 files changed, 1269 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/requests/channel.h b/protocols/FacebookRM/src/requests/channel.h
new file mode 100644
index 0000000000..03f36241df
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/channel.h
@@ -0,0 +1,101 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_CHANNEL_H_
+#define _FACEBOOK_REQUEST_CHANNEL_H_
+
+// receiving updates, sending activity ping
+class ChannelRequest : public HttpRequest
+{
+public:
+ enum Type { PULL, PING };
+
+ ChannelRequest(facebook_client *fc, Type type) :
+ HttpRequest(REQUEST_POST, FORMAT,
+ type == PULL ? FACEBOOK_SERVER_CHAT "/pull" : FACEBOOK_SERVER_CHAT "/active_ping",
+ fc->chat_conn_num_.empty() ? "0" : fc->chat_conn_num_.c_str(),
+ fc->chat_channel_host_.c_str())
+ {
+ if (type == PULL) {
+ timeout = 65 * 1000;
+ }
+
+ bool isPing = (type == PING);
+
+ Url << CHAR_VALUE("channel", fc->chat_channel_.empty() ? ("p_" + fc->self_.user_id).c_str() : fc->chat_channel_.c_str());
+ if (!isPing)
+ Url << CHAR_VALUE("seq", fc->chat_sequence_num_.empty() ? "0" : fc->chat_sequence_num_.c_str());
+
+ Url
+ << CHAR_VALUE("partition", fc->chat_channel_partition_.empty() ? "0" : fc->chat_channel_partition_.c_str())
+ << CHAR_VALUE("clientid", fc->chat_clientid_.c_str())
+ << CHAR_VALUE("cb", utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz", &fc->random_).c_str());
+
+ /*
+ original cb = return (1048576 * Math.random() | 0).toString(36);
+ char buffer[10];
+ itoa(((int)(1048576 * (((double)rand()) / (RAND_MAX + 1))) | 0), buffer, 36);
+ Url << CHAR_VALUE("cb", buffer);
+ */
+
+ int idleSeconds = fc->parent->IdleSeconds();
+ if (idleSeconds > 0 && !fc->parent->isInvisible())
+ Url << INT_VALUE("idle", idleSeconds);
+
+ if (!isPing) {
+ Url << "qp=y"; // TODO: what's this item?
+ Url << "pws=fresh"; // TODO: what's this item?
+ Url << "isq=487632"; // TODO: what's this item?
+ Url << INT_VALUE("msgs_recv", fc->chat_msgs_recv_);
+ // TODO: sometimes there is &tur=1711 and &qpmade=<some actual timestamp> and &isq=487632
+ // Url << "request_batch=1"; // it somehow batches up more responses to one - then response has special "t=batched" type and "batches" array with the data
+ // Url << "msgr_region=LLA"; // it was here only for first pull, same as request_batch
+ }
+
+ Url << "cap=8" // TODO: what's this item? Sometimes it's 0, sometimes 8
+ << CHAR_VALUE("uid", fc->self_.user_id.c_str())
+ << CHAR_VALUE("viewer_uid", fc->self_.user_id.c_str());
+
+ if (!fc->chat_sticky_num_.empty() && !fc->chat_sticky_pool_.empty()) {
+ Url << CHAR_VALUE("sticky_token", fc->chat_sticky_num_.c_str());
+ Url << CHAR_VALUE("sticky_pool", fc->chat_sticky_pool_.c_str());
+ }
+
+ if (!isPing && !fc->chat_traceid_.empty())
+ Url << CHAR_VALUE("traceid", fc->chat_traceid_.c_str());
+
+ if (fc->parent->isInvisible())
+ Url << "state=offline";
+ else if (isPing || idleSeconds < 60)
+ Url << "state=active";
+
+ /*
+ Body
+ << "persistent=1"
+ << CHAR_VALUE("email", ptrA(mir_urlEncode(username)))
+ << CHAR_VALUE("pass", ptrA(mir_urlEncode(password)))
+ << CHAR_VALUE("lgndim", "eyJ3IjoxOTIwLCJoIjoxMDgwLCJhdyI6MTgzNCwiYWgiOjEwODAsImMiOjMyfQ==") // means base64 encoded: {"w":1920,"h":1080,"aw":1834,"ah":1080,"c":32}
+ << bodyData; // additional data parsed from form*/
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_CHANNEL_H_
diff --git a/protocols/FacebookRM/src/requests/contacts.h b/protocols/FacebookRM/src/requests/contacts.h
new file mode 100644
index 0000000000..823ebaf2b4
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/contacts.h
@@ -0,0 +1,191 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_CONTACTS_H_
+#define _FACEBOOK_REQUEST_CONTACTS_H_
+
+// getting frienship requests (using mobile website)
+class GetFriendshipsRequest : public HttpRequest
+{
+public:
+ GetFriendshipsRequest(bool mobileBasicWorks) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/friends/center/requests/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
+ {
+ flags |= NLHRF_REDIRECT;
+ }
+};
+
+
+// getting info about particular friend
+// revised 17.8.2016
+class UserInfoRequest : public HttpRequest
+{
+public:
+ UserInfoRequest(facebook_client *fc, const LIST<char> &userIds) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info/")
+ {
+ Url
+ << "dpr=1";
+
+ for (int i = 0; i < userIds.getCount(); i++) {
+ CMStringA id(::FORMAT, "ids[%i]", i);
+ Body << CHAR_VALUE(id, ptrA(mir_urlEncode(userIds[i])));
+ }
+
+ Body
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+// getting info about all friends
+// revised 17.8.2016
+class UserInfoAllRequest : public HttpRequest
+{
+public:
+ UserInfoAllRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/chat/user_info_all/")
+ {
+ Url
+ << "dpr=1"
+ << CHAR_VALUE("viewer", fc->self_.user_id.c_str());
+
+ Body
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+// requesting friendships
+class AddFriendRequest : public HttpRequest
+{
+public:
+ AddFriendRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/add_friend/action.php")
+ {
+ Url
+ << "__a=1";
+
+ Body
+ << CHAR_VALUE("to_friend", userId)
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << "action=add_friend"
+ << "how_found=profile_button"
+ << "ref_param=ts"
+ << "outgoing_id="
+ << "unwanted="
+ << "logging_location="
+ << "no_flyout_on_click=false"
+ << "ego_log_data="
+ << "lsd=";
+ }
+};
+
+// deleting friendships
+class DeleteFriendRequest : public HttpRequest
+{
+public:
+ DeleteFriendRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/profile/removefriendconfirm.php")
+ {
+ Url
+ << "__a=1"
+ << "norefresh=true"
+ << "unref=button_dropdown"
+ << CHAR_VALUE("uid", userId);
+
+ Body
+ << CHAR_VALUE("uid", userId)
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << "norefresh=true"
+ << "unref=button_dropdown"
+ << "confirmed=1"
+ << "__a=1";
+ }
+};
+
+// canceling (our) friendship request
+class CancelFriendshipRequest : public HttpRequest
+{
+public:
+ CancelFriendshipRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/friends/requests/cancel.php")
+ {
+ Url
+ << "__a=1";
+
+ Body
+ << "confirmed=1"
+ << CHAR_VALUE("friend", userId)
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ }
+};
+
+// approving or ignoring friendship requests
+class AnswerFriendshipRequest : public HttpRequest
+{
+public:
+ enum Answer { CONFIRM, REJECT };
+
+ AnswerFriendshipRequest(facebook_client *fc, const char *userId, Answer answer) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/requests/friends/ajax/")
+ {
+ Url
+ << "__a=1";
+
+ const char *action = "";
+ switch (answer) {
+ case CONFIRM:
+ action = "confirm";
+ break;
+ case REJECT:
+ action = "reject";
+ break;
+ }
+
+ Body
+ << CHAR_VALUE("action", action)
+ << CHAR_VALUE("id", userId)
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_CONTACTS_H_
diff --git a/protocols/FacebookRM/src/requests/feeds.h b/protocols/FacebookRM/src/requests/feeds.h
new file mode 100644
index 0000000000..70e590d959
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/feeds.h
@@ -0,0 +1,60 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_FEEDS_H_
+#define _FACEBOOK_REQUEST_FEEDS_H_
+
+// getting newsfeed posts
+class NewsfeedRequest : public HttpRequest
+{
+public:
+ NewsfeedRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/home/generic.php")
+ {
+ Url
+ << fc->get_newsfeed_type().c_str()
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << "__a=1";
+ }
+};
+
+// getting memories ("on this day") posts
+class MemoriesRequest : public HttpRequest
+{
+public:
+ MemoriesRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/onthisday/story/query/")
+ {
+ Url
+ << "__a=1"
+ << "start_index=0"
+ << "num_stories=20"
+ << "last_section_header=0"
+ << LONG_VALUE("timestamp", ::time(NULL))
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_FEEDS_H_
diff --git a/protocols/FacebookRM/src/requests/history.h b/protocols/FacebookRM/src/requests/history.h
new file mode 100644
index 0000000000..426266c569
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/history.h
@@ -0,0 +1,167 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_HISTORY_H_
+#define _FACEBOOK_REQUEST_HISTORY_H_
+
+// getting thread info and messages
+// revised 17.8.2016
+class ThreadInfoRequest : public HttpRequest
+{
+public:
+ // Request only messages history
+ ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, int offset, const char *timestamp, int limit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php")
+ {
+ Url
+ << "dpr=1";
+
+ setCommonBody(fc);
+
+ const char *type = isChat ? "thread_ids" : "user_ids";
+ ptrA idEncoded(mir_urlEncode(id));
+
+ //if (loadMessages) {
+ // Grrr, offset doesn't work at all, we need to use timestamps to get back in history...
+ // And we don't know, what's timestamp of first message, so we need to get from latest to oldest
+ CMStringA begin(::FORMAT, "messages[%s][%s]", type, idEncoded);
+
+ Body
+ << CMStringA(::FORMAT, "%s[offset]=%i", begin, offset).c_str()
+ << CMStringA(::FORMAT, "%s[timestamp]=%s", begin, timestamp).c_str()
+ << CMStringA(::FORMAT, "%s[limit]=%i", begin, limit).c_str();
+ //}
+
+ /*if (loadThreadInfo) {
+ data += "&threads[" + type + "][0]=" + idEncoded;
+ }*/
+ }
+
+ // Request only thread info // TODO: Make it array of ids
+ ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php")
+ {
+ Url
+ << "dpr=1";
+
+ setCommonBody(fc);
+
+ const char *type = isChat ? "thread_ids" : "user_ids";
+ ptrA idEncoded(mir_urlEncode(id));
+
+ // Load only thread info
+ Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str();
+ }
+
+ // Request both thread info and messages for single contact/chat
+ ThreadInfoRequest(facebook_client *fc, bool isChat, const char *id, int limit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php")
+ {
+ Url
+ << "dpr=1";
+
+ setCommonBody(fc);
+
+ const char *type = isChat ? "thread_ids" : "user_ids";
+ ptrA idEncoded(mir_urlEncode(id));
+
+ // Load messages
+ CMStringA begin(::FORMAT, "messages[%s][%s]", type, idEncoded);
+
+ Body
+ << CMStringA(::FORMAT, "%s[offset]=%i", begin, 0).c_str()
+ << CMStringA(::FORMAT, "%s[timestamp]=%s", begin, "").c_str()
+ << CMStringA(::FORMAT, "%s[limit]=%i", begin, limit).c_str();
+
+ // Load thread info
+ Body << CMStringA(::FORMAT, "threads[%s][0]=%s", type, idEncoded).c_str();
+ }
+
+ // Request both thread info and messages for more threads
+ ThreadInfoRequest(facebook_client *fc, const LIST<char> &ids, int offset, int limit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/thread_info.php")
+ {
+ Url
+ << "dpr=1";
+
+ setCommonBody(fc);
+
+ for (int i = 0; i < ids.getCount(); i++) {
+ ptrA idEncoded(mir_urlEncode(ids[i]));
+
+ // Load messages
+ CMStringA begin(::FORMAT, "messages[%s][%s]", "thread_ids", idEncoded);
+ Body
+ << CMStringA(::FORMAT, "%s[offset]=%i", begin, offset).c_str()
+ //<< CMStringA(::FORMAT, "%s[timestamp]=%s", begin, "").c_str()
+ << CMStringA(::FORMAT, "%s[limit]=%i", begin, limit).c_str();
+
+ // Load thread info
+ Body << CMStringA(::FORMAT, "threads[%s][%i]=%s", "thread_ids", i, idEncoded).c_str();
+ }
+ }
+
+private:
+ void setCommonBody(facebook_client *fc)
+ {
+ Body
+ << "client=mercury"
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+// getting unread threads
+// revised 17.8.2016
+class UnreadThreadsRequest : public HttpRequest
+{
+public:
+ UnreadThreadsRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/unread_threads.php")
+ {
+ Url
+ << "dpr=1";
+
+ Body
+ << "folders[0]=inbox"
+ << "folders[1]=other" // TODO: "other" is probably unused, and there is now "pending" instead
+ << "client=mercury"
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_HISTORY_H_
diff --git a/protocols/FacebookRM/src/requests/login.h b/protocols/FacebookRM/src/requests/login.h
new file mode 100644
index 0000000000..85a2da36c6
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/login.h
@@ -0,0 +1,116 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_LOGIN_H_
+#define _FACEBOOK_REQUEST_LOGIN_H_
+
+// connecting physically
+class LoginRequest : public HttpRequest
+{
+public:
+ LoginRequest() :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
+ {
+ Url
+ << "login_attempt=1";
+ }
+
+ LoginRequest(const char *username, const char *password, const char *urlData, const char *bodyData) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_LOGIN "/login.php")
+ {
+ Url
+ << "login_attempt=1"
+ << urlData; // additional data parsed from form
+
+ Body
+ << "persistent=1"
+ << CHAR_VALUE("email", ptrA(mir_urlEncode(username)))
+ << CHAR_VALUE("pass", ptrA(mir_urlEncode(password)))
+ << CHAR_VALUE("lgndim", "eyJ3IjoxOTIwLCJoIjoxMDgwLCJhdyI6MTgzNCwiYWgiOjEwODAsImMiOjMyfQ==") // means base64 encoded: {"w":1920,"h":1080,"aw":1834,"ah":1080,"c":32}
+ << bodyData; // additional data parsed from form
+ }
+};
+
+// request to receive login code via SMS
+class LoginSmsRequest : public HttpRequest
+{
+public:
+ LoginSmsRequest(facebook_client *fc, const char *dtsg) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/login/approvals/send_sms")
+ {
+ Url
+ << "dpr=1";
+
+ Body
+ << "method_requested=sms_requested"
+ << "__a=1"
+ << "__user=0"
+ << "__be=0"
+ << "__pc=EXP1:DEFAULT"
+ << CHAR_VALUE("current_time", (utils::time::unix_timestamp() + ".000").c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("fb_dtsg", dtsg)
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__rev", fc->__rev());
+ }
+};
+
+// setting machine name
+class SetupMachineRequest : public HttpRequest
+{
+public:
+ SetupMachineRequest() :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
+ {
+ Url
+ << "next";
+ }
+
+ SetupMachineRequest(const char *dtsg, const char *nh, const char *submit) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/checkpoint/")
+ {
+ Url
+ << "next";
+
+ Body
+ << CMStringA(::FORMAT, "submit[%s]=%s", submit, submit).c_str()
+ << CHAR_VALUE("nh", nh)
+ << CHAR_VALUE("fb_dtsg", dtsg);
+ }
+};
+
+// disconnecting physically
+class LogoutRequest : public HttpRequest
+{
+public:
+ LogoutRequest(const char *dtsg, const char *logoutHash) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/logout.php")
+ {
+ Body
+ << "ref="
+ << CHAR_VALUE("fb_dtsg", dtsg)
+ << CHAR_VALUE("h", logoutHash);
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_LOGIN_H_
diff --git a/protocols/FacebookRM/src/requests/messages.h b/protocols/FacebookRM/src/requests/messages.h
new file mode 100644
index 0000000000..a9427e401a
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/messages.h
@@ -0,0 +1,161 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright � 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_MESSAGES_H_
+#define _FACEBOOK_REQUEST_MESSAGES_H_
+
+// sending messages
+// revised 17.8.2016
+class SendMessageRequest : public HttpRequest
+{
+public:
+ SendMessageRequest(facebook_client *fc, const char *userId, const char *threadId, const char *messageId, const char *messageText, bool isChat, const char *captcha, const char *captchaPersistData) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/messaging/send/")
+ {
+ // Don't notify errors for this request, because we're getting them inline in messaging window
+ NotifyErrors = false;
+
+ Url
+ << "dpr=1";
+
+ if (mir_strlen(captcha) > 0) {
+ Body
+ << CHAR_VALUE("captcha_persist_data", captchaPersistData)
+ << "recaptcha_challenge_field="
+ << CHAR_VALUE("captcha_response", captcha);
+ }
+
+ Body
+ << "client=mercury" // or "web_messenger" (whole messages page)
+ << "action_type=ma-type:user-generated-message";
+
+ // Experimental sticker sending support
+ std::string message_text = messageText; // FIXME: Rewrite this without std::string...
+ if (message_text.substr(0, 10) == "[[sticker:" && message_text.substr(message_text.length() - 2) == "]]") {
+ Body
+ << "body="
+ << CHAR_VALUE("sticker_id", ptrA(mir_urlEncode(message_text.substr(10, message_text.length() - 10 - 2).c_str())))
+ << "has_attachment=true";
+ // TODO: For sending GIF images instead of "sticker_id=" there is "image_ids[0]=", otherwise it's same
+ }
+ else {
+ Body
+ << CHAR_VALUE("body", ptrA(mir_urlEncode(messageText)))
+ << "has_attachment=false";
+ }
+
+ Body
+ << "ephemeral_ttl_mode=0"
+ // << "force_sms=true" // TODO: This is present always when sending via "web_messenger"
+ << CHAR_VALUE("message_id", messageId)
+ << CHAR_VALUE("offline_threading_id", messageId); // Same as message ID
+
+ if (isChat) {
+ // NOTE: Remove "id." prefix as here we need to give threadFbId and not threadId
+ std::string threadFbid = threadId; // FIXME: Rewrite this without std::string...
+ if (threadFbid.substr(0, 3) == "id.")
+ threadFbid = threadFbid.substr(3);
+
+ Body << CHAR_VALUE("thread_fbid", threadFbid.c_str());
+ }
+ else {
+ Body
+ << CHAR_VALUE("other_user_fbid", userId)
+ << CHAR_VALUE("specific_to_list[0]", CMStringA(::FORMAT, "fbid:%s", userId))
+ << CHAR_VALUE("specific_to_list[1]", CMStringA(::FORMAT, "fbid:%s", fc->self_.user_id.c_str()));
+ }
+
+ Body
+ << "signature_id=" // TODO: How to generate signature ID? It is present only when sending via "mercury"
+ << "source=source:chat:web" // or "source:titan:web" for web_messenger
+ << CHAR_VALUE("timestamp", utils::time::mili_timestamp().c_str())
+ << "ui_push_phase=V3"
+
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+// sending typing notification
+// revised 17.8.2016
+class SendTypingRequest : public HttpRequest
+{
+public:
+ SendTypingRequest(facebook_client *fc, const char *userId, bool isChat, bool isTyping) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/messaging/typ.php")
+ {
+ Url
+ << "dpr=1";
+
+ ptrA idEncoded(mir_urlEncode(userId));
+
+ Body
+ << (isTyping ? "typ=1" : "typ=0")
+ << CHAR_VALUE("to", isChat ? "" : idEncoded)
+ << CHAR_VALUE("thread", idEncoded)
+ << "source=mercury-chat"
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1";
+ }
+};
+
+// marking messages read
+class MarkMessageReadRequest : public HttpRequest
+{
+public:
+ MarkMessageReadRequest(facebook_client *fc, const LIST<char> &ids) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/mercury/change_read_status.php")
+ {
+ Url
+ << "__a=1";
+
+ for (int i = 0; i < ids.getCount(); i++) {
+ CMStringA id(::FORMAT, "ids[%s]=true", ptrA(mir_urlEncode(ids[i])));
+ Body << id.c_str();
+ }
+
+ Body
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << "__a=1";
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_MESSAGES_H_
diff --git a/protocols/FacebookRM/src/requests/notifications.h b/protocols/FacebookRM/src/requests/notifications.h
new file mode 100644
index 0000000000..4937c5d5bf
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/notifications.h
@@ -0,0 +1,75 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_NOTIFICATIONS_H_
+#define _FACEBOOK_REQUEST_NOTIFICATIONS_H_
+
+// getting notifications
+// revised 17.8.2016
+class GetNotificationsRequest : public HttpRequest
+{
+public:
+ GetNotificationsRequest(facebook_client *fc, int count) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/notifications/client/get.php")
+ {
+ Url
+ << "dpr=1";
+
+ Body
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << "cursor=" // when loading more
+ << INT_VALUE("length", count) // number of items to load
+ << "businessID=" // probably for pages?
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1"
+ << "__a=1";
+ }
+};
+
+// marking notifications read
+// request revised 11.2.2016 (we're not using the main website request, as it doesn't work, but still the old one with GET parameters)
+class MarkNotificationReadRequest : public HttpRequest
+{
+public:
+ MarkNotificationReadRequest(facebook_client *fc, const char *id) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/notifications/mark_read.php")
+ {
+ Url
+ << "__a=1"
+ << "seen=0"
+ << "asyncSignal="
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("alert_ids%5B0%5D", ptrA(mir_urlEncode(id)));
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_NOTIFICATIONS_H_
diff --git a/protocols/FacebookRM/src/requests/profile.h b/protocols/FacebookRM/src/requests/profile.h
new file mode 100644
index 0000000000..2eecbac018
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/profile.h
@@ -0,0 +1,83 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_PROFILE_H_
+#define _FACEBOOK_REQUEST_PROFILE_H_
+
+// getting own name, avatar, ...
+class HomeRequest : public HttpRequest
+{
+public:
+ HomeRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/profile.php")
+ {
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << "v=info";
+ }
+};
+
+// getting fb_dtsg
+class DtsgRequest : public HttpRequest
+{
+public:
+ DtsgRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_MOBILE "/editprofile.php")
+ {
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << "edit=current_city"
+ << "type=basic";
+ }
+};
+
+// request mobile page containing profile picture
+class ProfilePictureRequest : public HttpRequest
+{
+public:
+ ProfilePictureRequest(bool mobileBasicWorks, const char *userId) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/profile/picture/view/", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE)
+ {
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << CHAR_VALUE("profile_id", userId);
+ }
+};
+
+// request mobile page containing user profile
+class ProfileRequest : public HttpRequest
+{
+public:
+ ProfileRequest(bool mobileBasicWorks, const char *data) :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/%s", mobileBasicWorks ? FACEBOOK_SERVER_MBASIC : FACEBOOK_SERVER_MOBILE, data)
+ {
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << "v=info";
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_PROFILE_H_
diff --git a/protocols/FacebookRM/src/requests/search.h b/protocols/FacebookRM/src/requests/search.h
new file mode 100644
index 0000000000..0b4e777874
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/search.h
@@ -0,0 +1,46 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_SEARCH_H_
+#define _FACEBOOK_REQUEST_SEARCH_H_
+
+// searching
+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)
+ {
+ flags |= NLHRF_REDIRECT;
+
+ Url
+ << "search=people"
+ << CHAR_VALUE("query", query)
+ << INT_VALUE("s", s);
+
+ if (mir_strlen(ssid) > 0) {
+ Url << CHAR_VALUE("ssid", ssid);
+ }
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_SEARCH_H_
diff --git a/protocols/FacebookRM/src/requests/status.h b/protocols/FacebookRM/src/requests/status.h
new file mode 100644
index 0000000000..f832a00062
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/status.h
@@ -0,0 +1,74 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_STATUS_H_
+#define _FACEBOOK_REQUEST_STATUS_H_
+
+// getting info about channel and connecting to it
+// revised 17.8.2016
+class ReconnectRequest : public HttpRequest
+{
+public:
+ ReconnectRequest(facebook_client *fc) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/ajax/presence/reconnect.php")
+ {
+ Url
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1"
+ << CHAR_VALUE("reason", fc->chat_reconnect_reason_.empty() ? "6" : fc->chat_reconnect_reason_.c_str())
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev());
+ }
+};
+
+// setting chat visibility
+// revised 17.8.2016
+class SetVisibilityRequest : public HttpRequest
+{
+public:
+ SetVisibilityRequest(facebook_client *fc, bool online) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/chat/privacy/visibility.php")
+ {
+ Url
+ << "dpr=1";
+
+ Body
+ << (online ? "visibility=1" : "visibility=0")
+ << "window_id=0"
+ << "__a=1"
+ << "__pc=PHASED:DEFAULT"
+ << "__be=-1"
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev());
+ ;
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_STATUS_H_
diff --git a/protocols/FacebookRM/src/requests/utils.h b/protocols/FacebookRM/src/requests/utils.h
new file mode 100644
index 0000000000..a9f6d548cb
--- /dev/null
+++ b/protocols/FacebookRM/src/requests/utils.h
@@ -0,0 +1,195 @@
+/*
+
+Facebook plugin for Miranda Instant Messenger
+_____________________________________________
+
+Copyright © 2011-16 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
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _FACEBOOK_REQUEST_UTILS_H_
+#define _FACEBOOK_REQUEST_UTILS_H_
+
+// refreshing captcha dialog (changing captcha type)
+class RefreshCaptchaRequest : public HttpRequest
+{
+public:
+ RefreshCaptchaRequest(facebook_client *fc, const char *captchaPersistData) :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/captcha/refresh_ajax.php")
+ {
+ Url
+ << "__a=1"
+ << "new_captcha_type=TFBCaptcha"
+ << CHAR_VALUE("skipped_captcha_data", captchaPersistData)
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("__rev", fc->__rev())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str());
+ }
+};
+
+// getting data for given url (for sending/posting reasons)
+class LinkScraperRequest : public HttpRequest
+{
+public:
+ LinkScraperRequest(facebook_client *fc, status_data *status) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/composerx/attachment/link/scraper/")
+ {
+ Url
+ << "__a=1"
+ << "composerurihash=2"
+ << CHAR_VALUE("scrape_url", ptrA(mir_urlEncode(status->url.c_str())));
+
+ Body
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << CHAR_VALUE("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << "istimeline=1"
+ << "composercontext=composer"
+ << "onecolumn=1"
+ << "nctr[_mod]=pagelet_timeline_recent"
+ << "__a=1"
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
+ << "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";
+ }
+};
+
+// getting owned/admined pages list
+class GetPagesRequest : public HttpRequest
+{
+public:
+ GetPagesRequest() :
+ HttpRequest(REQUEST_GET, FACEBOOK_SERVER_REGULAR "/bookmarks/pages")
+ { }
+};
+
+// changing identity to post status for pages
+class SwitchIdentityRequest : public HttpRequest
+{
+public:
+ SwitchIdentityRequest(const char *dtsg, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/identity_switch.php")
+ {
+ Url
+ << "__a=1";
+
+ Body
+ << CHAR_VALUE("fb_dtsg", dtsg)
+ << CHAR_VALUE("user_id", userId)
+ << CHAR_VALUE("url", FACEBOOK_URL_HOMEPAGE);
+ }
+};
+
+// posting status to our or friends's wall
+class SharePostRequest : public HttpRequest
+{
+public:
+ SharePostRequest(facebook_client *fc, status_data *status, const char *linkData) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/ajax/updatestatus.php")
+ {
+ Url
+ << "__a=1";
+
+ ptrA text(mir_urlEncode(status->text.c_str()));
+
+ Body
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__dyn", fc->__dyn())
+ << CHAR_VALUE("__req", fc->__req())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str())
+ << CHAR_VALUE("__user", status->isPage && !status->user_id.empty() ? status->user_id.c_str() : fc->self_.user_id.c_str())
+ << CHAR_VALUE("xhpc_targetid", status->user_id.empty() ? fc->self_.user_id.c_str() : status->user_id.c_str())
+ << CHAR_VALUE("xhpc_message", text)
+ << CHAR_VALUE("xhpc_message_text", text)
+ << "xhpc_context=profile"
+ << "xhpc_ismeta=1"
+ << "xhpc_timeline=1"
+ << "xhpc_composerid=u_0_2y"
+ << "is_explicit_place="
+ << "composertags_place="
+ << "composertags_city="
+ << "composer_session_id="
+ << "composer_predicted_city="
+ << "disable_location_sharing=false"
+ << "nctr[_mod]=pagelet_composer";
+
+ if (!status->isPage) {
+ Body << CHAR_VALUE("audience[0][value]", fc->get_privacy_type().c_str());
+ }
+
+ if (!status->place.empty()) {
+ Body << CHAR_VALUE("composertags_place_name", ptrA(mir_urlEncode(status->place.c_str())));
+ }
+
+ // Status with users
+ for (std::vector<facebook_user*>::size_type i = 0; i < status->users.size(); i++) {
+ CMStringA withId(::FORMAT, "composertags_with[%i]", i);
+ CMStringA withName(::FORMAT, "text_composertags_with[%i]", i);
+
+ Body
+ << CHAR_VALUE(withId.c_str(), status->users[i]->user_id.c_str())
+ << CHAR_VALUE(withName.c_str(), status->users[i]->real_name.c_str());
+ }
+
+ // Link attachment
+ if (mir_strlen(linkData) > 0) {
+ Body
+ << linkData;
+ // << "no_picture=0" // for disabling link preview image
+ }
+ }
+};
+
+// sending pokes
+class SendPokeRequest : public HttpRequest
+{
+public:
+ SendPokeRequest(facebook_client *fc, const char *userId) :
+ HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/pokes/dialog/")
+ {
+ Url
+ << "__a=1";
+
+ Body
+ << "do_confirm=0"
+ << CHAR_VALUE("poke_target", userId)
+ << CHAR_VALUE("fb_dtsg", fc->dtsg_.c_str())
+ << CHAR_VALUE("__user", fc->self_.user_id.c_str())
+ << CHAR_VALUE("ttstamp", fc->ttstamp_.c_str());
+ }
+};
+
+#endif //_FACEBOOK_REQUEST_UTILS_H_