public int sendMessage(string UserId, string Message) { ZaloClient client = new ZaloClient("0__XHlbWJHG2_-P9yMTA6Wdzw4BrV3z4QUlhLTGMFKzBZUX0zXSN7cw1s2_FLm8mMvF8BwLl6J00aT0oZszv52ArfnwJQqu_CRwO9BrdLYiHe_Goe7yw3WcWvXot8Zi64kAK3hSCVoipoPmEe20s3aRMvnJbE3epQiFJ8V412mzovji0_puo2d_ed1dM0rK2Ki-OMSOIMsL9qxPNun1gIK_vl4_q1M5BLVEGIz8_Creeflr_kdmV9IQhz2-OHLy2C9hq6Ava8ZetkECVh7GA6Y-tsa7Bhvjh-tvB70"); JObject result = client.sendTextMessageToUserId(UserId, Message); return(result.Count); }
public frmZaloResource() { InitializeComponent(); tlResource.MouseDoubleClick += new MouseEventHandler(tlResource_MouseDoubleClick); tlResource.MouseClick += new MouseEventHandler(tlResource_MouseClick); //cboFile_Type.SelectedValueChanged +=new EventHandler(cboFile_Type_SelectedValueChanged); //cboFile_Type.SelectedIndexChanged += new EventHandler(cboFile_Type_SelectedIndexChanged); string access_token = Utils.ReadConfigXML(AppConfigFile, "DataConnectionTable"); //ZaloAppInfo info = new ZaloAppInfo(3320005208606942018, "", "http://tuanviet-trading.com/"); client = new ZaloClient(access_token); }
public frmZaloResource() { InitializeComponent(); tlResource.MouseDoubleClick += new MouseEventHandler(tlResource_MouseDoubleClick); tlResource.MouseClick += new MouseEventHandler(tlResource_MouseClick); //cboFile_Type.SelectedValueChanged +=new EventHandler(cboFile_Type_SelectedValueChanged); //cboFile_Type.SelectedIndexChanged += new EventHandler(cboFile_Type_SelectedIndexChanged); string access_token = ElementHrm.sysZaloAccessToken; //ZaloAppInfo info = new ZaloAppInfo(3320005208606942018, "", "http://tuanviet-trading.com/"); client = new ZaloClient(access_token); }
public static void SendMessageToZalo(ZaloClient client, string FilePathZalo, string Is_SendZalo) { string strMsgLog = string.Empty; try { object objImage; string strMsg = string.Empty; string AttachmentId = string.Empty; string ZaloLink, FileName; string FileImg; //string strMa_Cbnv, strTen_Cbnv, strEmail, strMa_Kv, strMa_Loai2, strSubject; DataTable dtMsg = SQLExec.ExecuteReturnDt("Z_GetMessage_ToZalo"); if (dtMsg == null || dtMsg.Rows.Count == 0) { return; } foreach (DataRow drmsg in dtMsg.Rows) { int MsgID = Convert.ToInt32(drmsg["Ident00"]); ZaloLink = drmsg["ZaloLink"].ToString(); objImage = drmsg["File_Content"]; FileImg = FilePathZalo + @"\" + (drmsg["File_Tag"].ToString() == string.Empty ? String.Empty : drmsg["File_ID"].ToString() + "." + drmsg["File_Tag"].ToString()); //Common.WriteToFileZaloLog("Start Send Message ToZalo : " + FileImg); if (SaveZaloResource.LoadResourceImage(FileImg, objImage)) { ZaloFile Zfile = new ZaloFile(FileImg); Zfile.setMediaTypeHeader("Image/PNG"); JObject updatefile = client.uploadImageForOfficialAccountAPI(Zfile); dynamic dynObjFile = JsonConvert.DeserializeObject(updatefile.ToString()); AttachmentId = dynObjFile.data.attachment_id; } //Get list employee in branch //string strSQLEm = "Z_GetEmployee_ByTag " + drmsg["Ident00"] + ""; if (Is_SendZalo == "Y") { DataTable dtEmployee_Br = SQLExec.ExecuteReturnDt("Z_GetEmployee_ByTag " + MsgID.ToString()); if (dtEmployee_Br == null || dtEmployee_Br.Rows.Count == 0) { continue; } foreach (DataRow drR in dtEmployee_Br.Rows) { JObject jSendbr = client.sendImageMessageToUserIdByAttachmentId(drR["Zalo_ID"].ToString(), ZaloLink, AttachmentId); } } else { JObject jSend_hungnv = client.sendImageMessageToUserIdByAttachmentId("5643947530772678208", ZaloLink, AttachmentId); } SQLExec.Execute("Z_UpdateMessageZaloAfterSend " + MsgID.ToString()); } } catch (Exception ex) { //Common.WriteToFileZaloLog("Send Message to Zalo : " + strMsgLog + "-------------\n" + ex.ToString()); } }