public int CreateUser(OOPEZZ_DBEntities db, string PSID) { string fbtoken = AppInstance.getInstance().getFbPageToken(); string url = "https://graph.facebook.com/" + PSID + "?fields=first_name,last_name,gender&access_token=" + fbtoken; var request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = "application/json"; request.Method = "GET"; WebResponse response = request.GetResponse(); string result = new StreamReader(response.GetResponseStream()).ReadToEnd(); //UserAPITemplate userResponse = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<UserAPITemplate>(result); UserAPITemplate userResponse = JsonConvert.DeserializeObject <UserAPITemplate>(result); string name = Ulti.UnicodeDecode(userResponse.LastName + " " + userResponse.FirstName); USER user = new USER() { STATUS = 1, TOKEN = PSID, USERNAME = name }; db.USER.Add(user); db.SaveChanges(); return(user.PK_SEQ); }
public ActionResult Receive() { var query = Request.QueryString; if (query["hub.mode"] == "subscribe" && query["hub.verify_token"] == AppInstance.getInstance().getFbverify_token()) { //string type = Request.QueryString["type"]; var retVal = query["hub.challenge"]; return(Json(int.Parse(retVal), JsonRequestBehavior.AllowGet)); } else { return(HttpNotFound()); } }
public ActionResult ReceivePost(BotRequest data) { Task task = Task.Run(() => { foreach (var entry in data.entry) { foreach (var message in entry.messaging) { if (message.recipient.id.Equals(AppInstance.getInstance().getFbPageId())) { ProgressRequest(message); } } } }); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }