private void InitLoginUser() { //最好重试一次,网页中会cancel一次,在这之后会有一个post //https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify?lang=zh_CN&pass_ticket=q9X4H1zNLHLGOsETIoHTKMpzzcrHA%252FDdou1xySUFciAQq9VuZShpcDiBjtqeih3T //返回结果示例{"BaseResponse": {"Ret": 0,"ErrMsg": ""},"MsgID": "7436838215428686364"} debug("开始初始化登录用户"); var url = string.Format(Urls.InitUrl, Bit64Not(TimeTick), context.PassTicket); var body = JsonHelper.Serialize(new { context.BaseRequest }); var resposne = _http.Post(url, body); var init = JsonHelper.DeSerialize <WechatInit>(resposne); if (init.BaseResponse.Ret != 0) { var msg = "初始化登录用户失败,sessionId: " + task.Id; log.LogError(msg); throw new Exception(msg); } task.UserDisplay = init.User.DisplayName; task.Status = CleanStatus.Inited; task.UserDetail = JsonHelper.Serialize(init.User); update(); context.LoginUser = init.User; context.SyncKey = init.SyncKey; debug("初始化登录用户结束,登录用户显示名称: {0}", init.User.DisplayName); }
public void ProxyTest() { // Arrange IHttpProxy httpProxy = new HttpProxy(); string resource = "https://www.domain.com/api/items"; int itemId = 100; // Act var postResult = httpProxy.Post($"{resource}", new { ItemId = 100, ItemName = "Item Name" }); var putResult = httpProxy.Put($"{resource}/{itemId}", new { ItemName = "Item New Name" }); var getResult = httpProxy.Get($"{resource}/{itemId}"); var deleteResult = httpProxy.Delete($"{resource}/{itemId}"); // Assert Assert.AreEqual(201, postResult.HttpStatusCode); Assert.AreEqual(200, putResult.HttpStatusCode); Assert.AreEqual(200, getResult.HttpStatusCode); Assert.AreEqual(200, deleteResult.HttpStatusCode); }
public static async Task CreateNote(NoteItem item) { await HttpProxy.Post(item, "api/notes"); }