09/07/2022

Gửi tin nhắn lên toàn bộ room chatwork của bạn

 Nếu bạn dùng chatwork và đôi khi muốn gửi 1 thông báo tới tất cả các room/group mà bạn không muốn copy paste thì làm thế nào?

Nếu bạn biết code c#, hãy tham khảo đoạn code sau

Thứ nhất, lấy toàn bộ danh sách room bạn có, trước hết bạn cần có token cá nhân
hãy đăng nhập vào tài khoản chatwork của bạn rồi truy cập link sau để lấy token
https://www.chatwork.com/service/packages/chatwork/subpackages/api/token.php 

=====

//Hàm lấy danh sách room

public partial class ChatworkClient

{

public static List<RoomInfo> GetRooms(string token)

        {

            var client = new RestClient("https://api.chatwork.com/v2/rooms");

            client.Timeout = -1;

            var request = new RestRequest(Method.GET);

            request.AddHeader("X-ChatWorkToken", token);

            IRestResponse response = client.Execute(request);

            //Console.WriteLine(response.Content);

            if(response.IsSuccessful && !string.IsNullOrEmpty(response.Content))

            {

                var rooms = JsonConvert.DeserializeObject<List<RoomInfo>>(response.Content);

                return rooms;

            }

            return null;

        }
}

=====

//model RoomInfo:

public class RoomInfo

    {

        public int room_id { get; set; }

        public string name { get; set; }

    }

======
//Tiếp theo, thực hiện gửi tin nhắn
tham khảo thêm chatwork API: trang 25, 
[POST] /rooms/{room_id}/messages

https://download.chatwork.com/ChatWork_API_Documentation.pdf 

Đăng ký tên miền, hosting, máy chủ, thiết kế lập trình website theo yêu cầu

 Chính thức trở thành đơn vị cung cấp dịch vụ đăng ký tên miền quốc tế, tên miền Việt Nam hosting, máy chủ, cloud hosting, cloud server, ema...