플랫폼 기술-.NET SDK 사용 지침


환경 종속성

  • .NET Framework 2.0 이상(Windows Phone 플랫폼은 지원되지 않음)

사용 예 # 🎜🎜#

타오바오 현재 시스템 시간 확인

ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
TimeGetRequest req = new TimeGetRequest();
TimeGetResponse rsp = client.Execute(req);
Console.WriteLine(rsp.Body);

단일 거래 세부정보 확인

ITopClient client = new DefaultTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
TradeFullinfoGetRequest req = new TradeFullinfoGetRequest();
req.Fields = "tid,type,status,payment,orders";
req.Tid = 123456789L;
TradeFullinfoGetResponse rsp = client.Execute(req, sessionKey);
Console.WriteLine(rsp.Body);

실시간 메시지 알림 듣기

TmcClient client = new TmcClient("app_key", "app_secret", "default"); 
client.OnMessage += (s, e) => 
{ 
    try 
    { 
        Console.WriteLine(e.Message.Content); 
        Console.WriteLine(e.Message.Topic);
        // 默认不抛出异常则认为消息处理成功 
    } 
    catch (Exception exp) 
    { 
        Console.WriteLine(exp.StackTrace); 
        e.Fail(); // 消息处理失败回滚,服务端需要重发 
    } 
}; 
client.Connect("ws://mc.api.taobao.com/");
#🎜🎜 #일괄통화 API

BatchTopClient client = new BatchTopClient("http://gw.api.taobao.com/router/batch", "appkey", "appsecret", "json");
TimeGetRequest timeRequest = new TimeGetRequest();
AppipGetRequest ipRequest = new AppipGetRequest();
TopBatchRequest batch = new TopBatchRequest();
batch.AddRequest(timeRequest).AddRequest(ipRequest);
TopBatchResponse rsp = client.Execute(batch);
Console.WriteLine(rsp.Body);

서비스 주소

API 서비스 주소

QQ截图20170213154955.png메시지 서비스 주소# 🎜🎜#

고급 기능QQ截图20170213155016.png

응답 문자열을 객체로 해석하지 않습니다. (현재 XxxResponse에 포함된 객체는 null입니다.)

DefaultTopClient.SetDisableParser(true)
#🎜 🎜#간단한 JSON 구조를 사용하여 중복 JSON 노드 반환 및 제거

DefaultTopClient.SetUseSimplifyJson(true)

API 호출 로그 관리 취소


DefaultTopClient.SetDisableTrace(true)
#🎜 🎜#HTTPS 인증서 확인 무시(테스트 환경에서만 오픈 권장)

DefaultTopClient.SetIgnoreSSLCheck(true)

GZIP 압축 기능에 대한 응답 취소(GZIP 압축 기능은 네트워크 전송을 대폭 줄일 수 있으므로, 취소하지 않는 것이 좋습니다)

DefaultTopClient.SetUseGzipEncoding(false)

HTTP 연결 시간 초과 및 읽기 시간 초과 설정(네트워크 환경이 좋지 않을 경우 적절하게 늘릴 수 있음)

// HTTP等待请求开始返回的超时时间:默认20秒
DefaultTopClient.SetTimeout(20000L)
// HTTP等待读取数据完成的超时时间:默认60秒
DefaultTopClient.SetReadWriteTimeout(60000L)

로그 수정 관리 저장 경로

DefaultTopLogger.FilePath = "c:/tmp/topsdk.log";

API 호출 오류 발생 시 자동 재시도(일반적으로 ISP 오류는 성공적으로 재시도 가능)

AutoRetryTopClient client = new AutoRetryTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
client.SetMaxRetryCount(3);
client.SetRetryWaitTime(100L);
TimeGetRequest request = new TimeGetRequest();
TimeGetResponse response = client.Execute(request);
if (!response.IsError) {
    Console.WriteLine(response.Body);
}

API 호출 가장 가까운 라우팅(가장 가까운 TOP 선택) API 호출이 시작된 위치에 따라 호출할 컴퓨터실) # 🎜🎜#

ClusterTopClient client = new ClusterTopClient("http://gw.api.taobao.com/router/rest", "appkey", "appsecret", "json");
TimeGetRequest request = new TimeGetRequest();
TimeGetResponse response = client.Execute(request);
Console.WriteLine(response.Body);

Notes


ITopClient 구현 클래스는 모두 스레드로부터 안전하므로 모든 API 요청에 대해 새로운 ITopClient 구현 클래스를 생성해야 합니다

# 🎜🎜# ITopClient 구현 클래스의 인스턴스를 생성할 때 format=json을 지정하면 xml 형식에 비해 데이터 전송량이 줄어들고 API 요청 효율성 향상

FAQ
    # 🎜 🎜#
  • 이 문서에 대한 FAQ는 아직 없습니다
  • #🎜🎜 #