Exemple #1
0
        public void GetComments(String id, int count, GetCommentsCompleteHandler handler)
        {
            if (m_netEngine == null)
                m_netEngine = new DoubanNetEngine();
            RestRequest request = new RestRequest();
            request.Method = WebMethod.Get;
            request.Path = String.Format("shuo/v2/statuses/{0}/comments", id);
            request.AddParameter("count", count.ToString());

            m_netEngine.SendRequest(request, (DoubanSdkResponse response) =>
            {
                if (response.errCode == DoubanSdkErrCode.SUCCESS)
                {
                    GetCommentsEventArgs args = new GetCommentsEventArgs();
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<Comment>));
                    List<Comment> list = ser.ReadObject(response.stream) as List<Comment>;
                    args.comments = list;
                    args.errorCode = DoubanSdkErrCode.SUCCESS;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
                else
                {
                    GetCommentsEventArgs args = new GetCommentsEventArgs();
                    args.comments = null;
                    args.errorCode = response.errCode;
                    args.specificCode = response.specificCode;
                    handler(args);
                }
            });
        }
Exemple #2
0
 public void GetComments(String id,int count, GetCommentsCompleteHandler handler)
 {
     if (m_shuoAPI == null)
         m_shuoAPI = new ShuoAPI();
     m_shuoAPI.GetComments(id,count, handler);
 }