public void AddComments(String id, String text, CompleteHandler handler) { if (m_netEngine == null) m_netEngine = new DoubanNetEngine(); RestRequest request = new RestRequest(); request.Method = WebMethod.Post; request.Path = String.Format("shuo/v2/statuses/{0}/comments", id); request.AddParameter("text", text); request.AddParameter("source", DoubanSdkData.AppKey); m_netEngine.SendRequest(request, (DoubanSdkResponse response) => { if (response.errCode == DoubanSdkErrCode.SUCCESS) { DoubanEventArgs args = new DoubanEventArgs(); args.errorCode = DoubanSdkErrCode.SUCCESS; args.specificCode = response.specificCode; handler(args); } else { DoubanEventArgs args = new DoubanEventArgs(); args.errorCode = response.errCode; args.specificCode = response.specificCode; handler(args); } }); }
public void PostStatusesWithPic(String text, String path, CompleteHandler handler) { if (m_netEngine == null) m_netEngine = new DoubanNetEngine(); RestRequest request = new RestRequest(); request.Method = WebMethod.Post; request.Path = "shuo/v2/statuses/"; request.AddParameter("text", text); request.AddParameter("source", DoubanSdkData.AppKey); //path = ""; if (!String.IsNullOrEmpty(path)) { IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication(); if (!file.FileExists(path)) { file.Dispose(); DoubanEventArgs args = new DoubanEventArgs(); args.errorCode = DoubanSdkErrCode.XPARAM_ERR; handler(args); return; } file.Dispose(); string picType = System.IO.Path.GetExtension(path); string picName = System.IO.Path.GetFileName(path); if ("png" == picType) { request.AddFile("image", picName, path, "image/png"); } else { request.AddFile("image", picName, path, "image/jpeg"); } } m_netEngine.SendRequest(request, (DoubanSdkResponse response) => { if (response.errCode == DoubanSdkErrCode.SUCCESS) { DoubanEventArgs args = new DoubanEventArgs(); args.errorCode = DoubanSdkErrCode.SUCCESS; args.specificCode = response.specificCode; handler(args); } else { DoubanEventArgs args = new DoubanEventArgs(); args.errorCode = response.errCode; args.specificCode = response.specificCode; handler(args); } }); }