public string Active(string call_id, string direction, string remote_number) { RequestParams reqpar2 = new RequestParams(); reqpar2["event"] = "active"; reqpar2["call_id"] = call_id; reqpar2["direction"] = direction; reqpar2["remote_number"] = remote_number; using (xNet.HttpRequest request2 = new xNet.HttpRequest()) { xNet.HttpResponse content2 = request2.Post("https://legionsport.s20.online/api/1/sip/process?token=c4ca4238a0b923820dcc509a6f75849b", reqpar2); } return("ok"); }
//Закрытый метод для получения и записи Токенов авторизации private void RefSetToken(string portal) { amoCompan conm = _db.amoCompans.Where(i => i.PortalName == portal).FirstOrDefault(); // если токен свежий то выходим if (conm.DTRefTok.AddSeconds(-10) > DateTime.Now) { return; } xNet.HttpResponse resp2 = null; var data = new { client_id = amoFunction.ClienID, client_secret = amoFunction.ClientSecret, grant_type = "refresh_token", refresh_token = conm.RefTok, redirect_uri = amoFunction.RedirectUrl }; string contentText = JsonConvert.SerializeObject(data).ToString(); using (xNet.HttpRequest request = new xNet.HttpRequest()) { resp2 = request.Post("https://" + portal + "/oauth2/access_token", contentText, "application/json"); //Если в ответ получаем статус-код отличный от 200, то это ошибка, вызываем исключение if (resp2.StatusCode != HttpStatusCode.OK) { throw new FormatException("ErrorLogonBitrixOAuth"); } else { string stringLogonBitrixOAuth = resp2.ToString(); var converter = new ExpandoObjectConverter(); dynamic objLogonBitrixOAuth = JsonConvert.DeserializeObject <ExpandoObject>(stringLogonBitrixOAuth, converter); //Записывем Токены авторизации в поля нашего класса из динамического объекта conm.AcesTok = objLogonBitrixOAuth.access_token; conm.RefTok = objLogonBitrixOAuth.refresh_token; conm.DTRefTok = DateTime.Now.AddSeconds(objLogonBitrixOAuth.expires_in); //Добавляем к текущей дате количество секунд действия токена, обычно это плюс один час _db.Entry(conm).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); } } }
public string Close(string call_id, string direction, string remote_number, string USER_PHONE_INNER, string DURATION, string VI_STATUS, string finish_reason, string RECORD_URL) { RequestParams reqpar3 = new RequestParams(); reqpar3["event"] = "release"; reqpar3["call_id"] = call_id; reqpar3["direction"] = direction; reqpar3["local_number"] = USER_PHONE_INNER; reqpar3["duration"] = DURATION; reqpar3["is_success"] = VI_STATUS; reqpar3["remote_number"] = remote_number; reqpar3["finish_reason"] = finish_reason; reqpar3["record_url"] = RECORD_URL; using (xNet.HttpRequest request3 = new xNet.HttpRequest()) { xNet.HttpResponse content3 = request3.Post("https://legionsport.s20.online/api/1/sip/process?token=c4ca4238a0b923820dcc509a6f75849b", reqpar3); } return("ok"); }
private void Init() { KeepAlive = true; AllowAutoRedirect = true; EnableEncodingContent = true; EnableAdditionalHeaders = true; Address = new Uri("/", UriKind.Relative); _response = new HttpResponse(this); }
private void Init() { KeepAlive = true; AllowAutoRedirect = true; EnableEncodingContent = true; _response = new HttpResponse(this); }