public static AuthSlack createAuthSlack(string filePath) { AuthSlack result = null; try { if (filePath == null || filePath.Length <= 0) { result = null; return(result); } AuthSlack auth = null; if (UtilityJson.loadFromJson <AuthSlack>(out auth, filePath) != 0) { result = null; return(result); } result = auth; } catch (Exception ex) { Console.WriteLine("exception: {0}", ex.Message); result = null; } finally { } return(result); }
public static async Task <int> Request ( AuthSlack auth, string message ) { int result = 0; try { if (auth == null) { Console.WriteLine("auth is null."); result = -1; return(result); } if (message == null) { Console.WriteLine("message is null."); result = -1; return(result); } if (message.Length <= 0) { Console.WriteLine("message is 0."); result = -1; return(result); } string method = "POST"; string path = "/api/chat.postMessage"; string query = string.Format("?token={0}&channel={1}&text={2}&username={3}&icon_url={4}" , auth.token , auth.channel , message , auth.username , auth.icon_url ); path = path + query; string resJson = await RequestSlack.Request(method, path, null); if (resJson == null) { Console.WriteLine("failed to RequestSlack."); result = -1; return(result); } //Console.WriteLine(resJson); } catch (Exception ex) { Console.WriteLine(ex); result = -1; } finally { } return(result); }