std::string facebook_client::choose_action( int request_type, std::string* data, std::string* get_data ) { switch ( request_type ) { case FACEBOOK_REQUEST_LOGIN: return "/login.php?login_attempt=1"; case FACEBOOK_REQUEST_SETUP_MACHINE: return "/checkpoint/"; case FACEBOOK_REQUEST_LOGOUT: return "/logout.php"; case FACEBOOK_REQUEST_HOME: return "/home.php?_fb_noscript=1"; case FACEBOOK_REQUEST_BUDDY_LIST: return "/ajax/chat/buddy_list.php?__a=1"; case FACEBOOK_REQUEST_LOAD_FRIENDS: { std::string action = "/ajax/chat/user_info_all.php?__a=1&viewer=%s&__user=%s"; utils::text::replace_all( &action, "%s", self_.user_id ); return action; } case FACEBOOK_REQUEST_DELETE_FRIEND: { return "/ajax/profile/removefriend.php?__a=1"; } case FACEBOOK_REQUEST_ADD_FRIEND: { return "/ajax/add_friend/action.php?__a=1"; } case FACEBOOK_REQUEST_FEEDS: { std::string action = "/ajax/intent.php?filter="; action += get_newsfeed_type(); action += "&request_type=4&__a=1&newest=%s&ignore_self=true&load_newer=true&__user=%s"; std::string newest = utils::conversion::to_string((void*)&this->last_feeds_update_, UTILS_CONV_TIME_T); utils::text::replace_first( &action, "%s", newest ); utils::text::replace_first( &action, "%s", self_.user_id ); return action; } case FACEBOOK_REQUEST_NOTIFICATIONS: { std::string action = "/ajax/notifications/get.php?__a=1&user=%s&time=0&version=2&__user=%s"; utils::text::replace_all( &action, "%s", self_.user_id ); return action; } case FACEBOOK_REQUEST_RECONNECT: { std::string action = "/ajax/presence/reconnect.php?__a=1&reason=%s&fb_dtsg=%s&post_form_id=%s&__user=%s"; if (this->chat_reconnect_reason_.empty()) this->chat_reconnect_reason_ = "6"; utils::text::replace_first( &action, "%s", this->chat_reconnect_reason_ ); utils::text::replace_first( &action, "%s", this->dtsg_ ); utils::text::replace_first( &action, "%s", this->post_form_id_ ); utils::text::replace_first( &action, "%s", this->self_.user_id ); return action; } case FACEBOOK_REQUEST_STATUS_SET: return "/ajax/updatestatus.php?__a=1"; case FACEBOOK_REQUEST_MESSAGE_SEND: return "/ajax/chat/send.php?__a=1"; case FACEBOOK_REQUEST_MESSAGES_RECEIVE: { std::string action = "/x/%s/0/true/p_%s=%s"; if (!this->chat_channel_jslogger_.empty()) { action = "/pull?clientid=&channel=p_%s&seq=%s&cb=&state=active"; //utils::text::replace_first( &action, "%s", dtsg_ ); } else { utils::text::replace_first( &action, "%s", utils::time::unix_timestamp() ); } utils::text::replace_first( &action, "%s", self_.user_id ); utils::text::replace_first( &action, "%s", chat_sequence_num_.empty() ? "0" : chat_sequence_num_ ); return action; } case FACEBOOK_REQUEST_VISIBILITY: return "/ajax/chat/privacy/visibility.php?__a=1"; case FACEBOOK_REQUEST_TABS: return "/ajax/chat/tabs.php?__a=1"; case FACEBOOK_REQUEST_ASYNC: { std::string action = "/ajax/messaging/async.php?__a=1"; if (get_data != NULL) { action += "&" + (*get_data); } return action; } case FACEBOOK_REQUEST_TYPING_SEND: return "/ajax/messaging/typ.php?__a=1"; default: return "/?_fb_noscript=1"; } }
std::string facebook_client::choose_action(RequestType request_type, std::string* data, std::string* get_data) { switch (request_type) { case REQUEST_LOGIN: return "/login.php?login_attempt=1"; case REQUEST_SETUP_MACHINE: return "/checkpoint/?next"; case REQUEST_LOGOUT: return "/logout.php"; case REQUEST_HOME: return "/profile.php?v=info"; case REQUEST_DTSG: return "/editprofile.php?edit=current_city&type=basic"; case REQUEST_BUDDY_LIST: return "/ajax/chat/buddy_list.php?__a=1"; case REQUEST_LOAD_FRIEND: { std::string action = "/ajax/chat/user_info.php?__a=1&viewer=%s&__user=%s"; utils::text::replace_all(&action, "%s", self_.user_id); if (get_data != NULL) { action += "&" + (*get_data); } return action; } case REQUEST_LOAD_FRIENDS: { std::string action = "/ajax/chat/user_info_all.php?__a=1&viewer=%s&__user=%s"; utils::text::replace_all(&action, "%s", self_.user_id); return action; } case REQUEST_USER_INFO: { std::string action = "/%sv=info"; if (get_data != NULL) { utils::text::replace_all(&action, "%s", *get_data); } return action; } case REQUEST_LOAD_REQUESTS: { return "/friends/"; } case REQUEST_SEARCH: { std::string action = "/search/?search=people&query="; if (get_data != NULL) { action += *get_data; } return action; } case REQUEST_UNREAD_THREADS: { return "/ajax/mercury/unread_threads.php?__a=1"; } case REQUEST_DELETE_FRIEND: { std::string action = "/ajax/profile/removefriendconfirm.php?__a=1"; if (get_data != NULL) { action += *get_data; } return action; } case REQUEST_REQUEST_FRIEND: { return "/ajax/add_friend/action.php?__a=1"; } case REQUEST_APPROVE_FRIEND: { std::string action = "/a/notifications.php?__a=1"; if (get_data != NULL) { action += "&" + (*get_data); } return action; } case REQUEST_CANCEL_REQUEST: { return "/ajax/friends/requests/cancel.php?__a=1"; } case REQUEST_FEEDS: { std::string action = "/ajax/home/generic.php?" + get_newsfeed_type(); action += "&__user="******"&__a=1"; /*std::string newest = utils::conversion::to_string((void*)&this->last_feeds_update_, UTILS_CONV_TIME_T); utils::text::replace_first(&action, "%s", newest); utils::text::replace_first(&action, "%s", self_.user_id);*/ return action; } case REQUEST_PAGES: { return "/bookmarks/pages"; } case REQUEST_NOTIFICATIONS: { std::string action = "/ajax/notifications/get.php?__a=1&user=%s&time=0&version=2&__user=%s"; // TODO: use better format notifications request // std::string action = "/ajax/notifications/client/get.php?__a=1&user=%s&time=0&version=2&__user=%s"; utils::text::replace_all(&action, "%s", self_.user_id); return action; } case REQUEST_RECONNECT: { std::string action = "/ajax/presence/reconnect.php?__a=1&reason=%s&fb_dtsg=%s&__user=%s"; if (this->chat_reconnect_reason_.empty()) this->chat_reconnect_reason_ = "6"; utils::text::replace_first(&action, "%s", this->chat_reconnect_reason_); utils::text::replace_first(&action, "%s", this->dtsg_); utils::text::replace_first(&action, "%s", this->self_.user_id); return action; } case REQUEST_POST_STATUS: return "/ajax/updatestatus.php?__a=1"; case REQUEST_IDENTITY_SWITCH: return "/identity_switch.php?__a=1"; case REQUEST_STATUS_COMPOSER: return "/ajax/profile/composer.php?__a=1"; case REQUEST_LINK_SCRAPER: { std::string action = "/ajax/composerx/attachment/link/scraper/?__a=1&composerurihash=2&scrape_url="; if (get_data != NULL) { action += utils::url::encode(*get_data); } return action; } case REQUEST_MESSAGE_SEND: return "/ajax/mercury/send_messages.php?__a=1"; case REQUEST_MESSAGE_SEND2: return "/ajax/messaging/send.php"; case REQUEST_THREAD_INFO: return "/ajax/mercury/thread_info.php?__a=1"; case REQUEST_MESSAGES_RECEIVE: { std::string action = "/pull?channel=" + (this->chat_channel_.empty() ? "p_" + self_.user_id : this->chat_channel_); action += "&seq=" + (this->chat_sequence_num_.empty() ? "0" : this->chat_sequence_num_); action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_); action += "&clientid=" + this->chat_clientid_; action += "&cb=" + utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz"); // FIXME: fix this as I don't know how it works yet (because of quick stable release) if (!parent->isInvisible()) action += "&idle=-1&state=active"; else action += "&idle=1"; if (!this->chat_sticky_num_.empty()) action += "&sticky_token=" + this->chat_sticky_num_; return action; } case REQUEST_VISIBILITY: return "/ajax/chat/privacy/visibility.php?__a=1"; case REQUEST_POKE: return "/pokes/dialog/?__a=1"; case REQUEST_ASYNC: { std::string action = "/ajax/messaging/async.php?__a=1"; if (get_data != NULL) { action += "&" + (*get_data); } return action; } case REQUEST_MARK_READ: return "/ajax/mercury/change_read_status.php?__a=1"; case REQUEST_NOTIFICATIONS_READ: { std::string action = "/ajax/notifications/mark_read.php?__a=1"; if (get_data != NULL) { action += "&" + (*get_data); } return action; } case REQUEST_TYPING_SEND: return "/ajax/messaging/typ.php?__a=1"; default: return "/?_fb_noscript=1"; } }