Ejemplo n.º 1
0
        public static WWWForm GenerateUploadFileForm(string token,
                                                     string channel,
                                                     string username,
                                                     string text,
                                                     string filename,
                                                     byte[] filedata)
        {
            // NOTE:
            // This implementation is a small set. There is more info in API.
            // https://api.slack.com/methods/files.upload

            WWWForm wwwForm = SlackAPI.GenerateBaseForm(token);

            wwwForm.AddField("channels", channel);         // Required
            wwwForm.AddField("username", username);        // Optional
            if (text != null)
            {
                wwwForm.AddField("initial_comment", text);     // Optional
            }
            wwwForm.AddField("link_names", 1);                 // Optional

            wwwForm.AddBinaryData("file", filedata, filename); // Optional

            return(wwwForm);
        }
Ejemplo n.º 2
0
        public static WWWForm GenerateUserListForm(string token)
        {
            // NOTE:
            // https://api.slack.com/methods/users.list

            return(SlackAPI.GenerateBaseForm(token));
        }
Ejemplo n.º 3
0
        public static WWWForm GeneratePostMessageForm(string token,
                                                      string channel,
                                                      string username,
                                                      string text)
        {
            // NOTE:
            // This implementation is a small set. There is more info in API.
            // https://api.slack.com/methods/chat.postMessage

            // NOTE:
            // "link_names" is needed to make "#channel" text into link.

            WWWForm wwwForm = SlackAPI.GenerateBaseForm(token);

            wwwForm.AddField("channel", channel);     // Required
            wwwForm.AddField("text", text);           // Required
            wwwForm.AddField("username", username);   // Optional
            wwwForm.AddField("link_names", 1);        // Optional

            return(wwwForm);
        }