Mukesh

Mukesh

  • NA
  • 228
  • 39.5k

how to check messages read or not on whatsapp API Using C#

Dec 7 2018 3:15 AM
  1. function GetNotification() {  
  2. debugger;  
  3. $.ajax({  
  4. type: "POST",  
  5. url: "@Url.Action("GetNotification", "GetChat")",  
  6. data: "",  
  7. contentType: "application/json; charset=utf-8",  
  8. dataType: "json",  
  9. success: function (data) {  
  10. $('#dvMsg').empty();  
  11. debugger;  
  12. result = data;  
  13. $('#dvMsg').append('');  
  14. for (var j = 0; j < result.length; j++) {  
  15. $('#dvMsg').append('From:' + result[j].author + ' Message:' + result[j].body + '  
  16. ');  
  17. }  
  18. },  
  19. error: function (result) {  
  20. }  
  21. });  
  22. }  
  23. setInterval(showMessage, "100000");  
  24.    
  25. public JsonResult GetNotification()  
  26. {  
  27. WebClient client = new WebClient();  
  28. client.Headers["Content-type"] = "application/json";  
  29. client.Encoding = Encoding.UTF8;  
  30. //Testing tt = new Testing();  
  31. //tt.lastMessageNumber = "100";  
  32. string response_message = client.DownloadString(apiUrl + "messages?token=kzwfwna7auyj5ubp");  
  33. Messsage resp = (new JavaScriptSerializer()).Deserialize(response_message);  
  34. var data = resp.messages.Where(x => x.chatId == Convert.ToString(Session["ChatId"])).Select(x => new { x.body, x.author, x.time }).OrderBy(x => x.time).ToList();  
  35. return Json(data, JsonRequestBehavior.AllowGet);  
  36. }  

Answers (1)