/// <summary> /// Find and get a thread by its name /// </summary> /// <param name="name">Name of the thread</param> /// <param name="limit">The max. amount of threads to fetch</param> /// <returns>`FB_User`, `FB_Group` and `FB_Page` objects, ordered by relevance</returns> public async Task <List <FB_Thread> > searchThreads(string name, int limit = 1) { /* * Find and get a thread by its name * :param name: Name of the thread * :param limit: The max. amount of groups to fetch * : return: `User`, `Group` and `Page` objects, ordered by relevance * :rtype: list * :raises: FBchatException if request failed * */ var param = new Dictionary <string, object>() { { "search", name }, { "limit", limit.ToString() } }; var j = await this._session.graphql_request(GraphQL.from_query(GraphQL.SEARCH_THREAD, param)); List <FB_Thread> rtn = new List <FB_Thread>(); foreach (var node in j[name]?.get("threads")?.get("nodes")) { if (node.get("__typename").Value <string>().Equals("User")) { rtn.Add(FB_User._from_graphql(_session, node)); } else if (node.get("__typename").Value <string>().Equals("MessageThread")) { // MessageThread => Group thread rtn.Add(FB_Group._from_graphql(_session, node)); } else if (node.get("__typename").Value <string>().Equals("Page")) { rtn.Add(FB_Page._from_graphql(_session, node)); } else if (node.get("__typename").Value <string>().Equals("Group")) { // We don"t handle Facebook "Groups" continue; } else { Debug.WriteLine(string.Format("Unknown __typename: {0} in {1}", node.get("__typename").Value <string>(), node)); } } return(rtn); }
/// <summary> /// Find and get page by its name /// </summary> /// <param name="name">Name of the page</param> /// <param name="limit">The max. amount of pages to fetch</param> /// <returns>`FB_Page` objects, ordered by relevance</returns> public async Task <List <FB_Page> > searchPages(string name, int limit = 1) { /* * Find and get page by its name * : param name: Name of the page * :return: `Page` objects, ordered by relevance * :rtype: list * :raises: FBchatException if request failed * */ var param = new Dictionary <string, object>() { { "search", name }, { "limit", limit.ToString() } }; var j = await this._session.graphql_request(GraphQL.from_query(GraphQL.SEARCH_PAGE, param)); return(j[name]?.get("pages")?.get("nodes").Select(node => FB_Page._from_graphql(_session, node)).ToList()); }
/// <summary> /// Find and get group thread by its name /// </summary> /// <param name="name">Name of the group</param> /// <param name="limit">The max. amount of groups to fetch</param> /// <returns>`FB_Group` objects, ordered by relevance</returns> public async Task <List <FB_Group> > searchGroups(string name, int limit = 1) { /* * Find and get group thread by its name * :param name: Name of the group thread * :param limit: The max. amount of groups to fetch * :return: `Group` objects, ordered by relevance * :rtype: list * :raises: FBchatException if request failed * */ var param = new Dictionary <string, object>() { { "search", name }, { "limit", limit.ToString() } }; var j = await this._session.graphql_request(GraphQL.from_query(GraphQL.SEARCH_GROUP, param)); return(j.get("viewer")?.get("groups")?.get("nodes").Select(node => FB_Group._from_graphql(_session, node)).ToList()); }
/// <summary> /// Find and get user by his/her name /// </summary> /// <param name="name">Name of the user</param> /// <param name="limit">The max. amount of users to fetch</param> /// <returns>`FB_User` objects, ordered by relevance</returns> public async Task <List <FB_User> > searchUsers(string name, int limit = 10) { /* * Find and get user by his/ her name * : param name: Name of the user * :param limit: The max. amount of users to fetch * : return: `User` objects, ordered by relevance * :rtype: list * :raises: FBchatException if request failed * */ var param = new Dictionary <string, object>() { { "search", name }, { "limit", limit.ToString() } }; var j = await this._session.graphql_request(GraphQL.from_query(GraphQL.SEARCH_USER, param)); return(j[name]?.get("users")?.get("nodes").Select(node => FB_User._from_graphql(_session, node)).ToList()); }