public Zalo(DateTime time1, DateTime time2, DateTime time3, long Oaid, string SecretKey) { _time1 = time1; _time2 = time2; _time3 = time3; _OaId = Oaid; _SecretKey = SecretKey; _zaloOaInfo = new ZaloOaInfo(_OaId, SecretKey); _storeClient = new ZaloStoreClient(_zaloOaInfo); }
public static string GuiTinNhan(object[] userId, object noidung) { ZaloOaInfo zaloOaInfo = new ZaloOaInfo(739460368435099423, "n30YrpHUT626CuAUWW15"); ZaloOaClient oaClient = new ZaloOaClient(zaloOaInfo); JObject sendTextMessage = null; foreach (object x in userId) { sendTextMessage = oaClient.sendTextMessage(long.Parse(x.ToString()), noidung.ToString()); } //JObject sendTextMessage = oaClient.sendTextMessage(long.Parse(userId.ToString()), noidung.ToString()); return(sendTextMessage.ToString()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { tranghientai = "localhost:1834/zalo.aspx"; Zalo3rdAppClient appClient = new Zalo3rdAppClient(new Zalo3rdAppInfo(2127518896466871150, "OUKlCdL8uYLIMe73QB65", tranghientai)); string loginUrl = appClient.getLoginUrl(); code = Request.QueryString["code"]; JObject token = appClient.getAccessToken(code); if (string.IsNullOrEmpty(code)) { Response.Redirect(loginUrl.ToString()); } else { string chuoitoken = token.Property("access_token").Value.ToString(); JObject profile = appClient.getProfile(chuoitoken, "name,picture,id,userIdByOA"); // userIdByOA => ID cần gửi tin txtHDinfo.Value = profile.ToString(); //txtTenNguoiDung.Text = profile.Property("name").Value.ToString(); txtTenNguoiDung.Text = "NTSoft"; JObject invitableFriends = appClient.getInvitableFriends(chuoitoken, 0, 0, "id, name, picture, gender"); int soluong = 0; soluong = int.Parse(invitableFriends["summary"]["total_count"].ToString()); //JObject banbe = appClient.getInvitableFriends(chuoitoken, 0, soluong, "id, name, picture, gender,userIdByOA"); JObject banbe = JObject.Parse(JObject.Parse(new WebClient().DownloadString("https://openapi.zalo.me/v2.0/oa/getfollowers?access_token=w8i4LtUoispYX0XGUxoyOk633rryexLkf-1d5N-lg6-twqXHLRs2Q8dZH54MtvCfmfqXG2ltwtBMcoPA7lVnTSMD94WZnUGQ-89M91Yua6F-yoDS5CdZ8y-39s8szEymwhqQ3t_gqZ7ZfHft1CV83kg267HtkiWuWkv_V6oYgpwnWKX6RkkcVx6HTZ9Gsy9PZu4r6NRMW27hW4qV0CU4TfYdGZL-neDLw_bFQ16D_JNij0S86SB8OVFx6IOfagaSnVb9JmcVWn_qw5DIhGw22dQhj6m&data={offset=0,count=5}"))["data"].ToString()); string[,] mangid = new string[banbe["followers"].Count <JToken>(), 3]; ZaloOaInfo zaloOaInfo = new ZaloOaInfo(739460368435099423, "n30YrpHUT626CuAUWW15"); ZaloOaClient oaClient = new ZaloOaClient(zaloOaInfo); for (int i = 0; i < banbe["followers"].Count <JToken>(); i++) { long idphu = long.Parse(banbe["followers"][i].Value <JToken>()["user_id"].ToString()); JObject a1 = oaClient.getProfile(idphu); mangid[i, 0] = idphu.ToString(); mangid[i, 1] = a1["data"].Value <JToken>()["avatar"].ToString(); mangid[i, 2] = a1["data"].Value <JToken>()["displayName"].ToString(); } json_dsbb = JsonConvert.SerializeObject(mangid); } } catch (Exception ex) { Response.Write(ex.Message); } } }