Files
SOP/sop-sdk/sdk-go/readme.md
tanghc 6406f023db 3.2.0
2020-06-17 10:36:22 +08:00

43 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# sdk-go
```go
// 应用ID
const appId string = "xx"
// 应用私钥
const privateKey string = "xx"
// 请求地址
const url string = "http://localhost:7071/prod/gw68uy85"
// 请求客户端
var openClient = common.OpenClient{AppId: appId, PrivateKey: privateKey, Url: url}
func main() {
// 创建请求
memberInfoGetRequest := request.MemberInfoGetRequest{}
// 请求参数
memberInfoGetRequest.BizModel = model.MemberInfoGetModel{Name: "jim", Age: 22, Address: "xx"}
// 添加上传文件
//path, _ := os.Getwd()
//files := []common.UploadFile{
// {Name:"file1", Filepath:path + "/test/aa.txt"},
// {Name:"file2", Filepath:path + "/test/bb.txt"},
//}
//memberInfoGetRequest.Files = files
// 发送请求返回json bytes
var jsonBytes = openClient.Execute(memberInfoGetRequest)
fmt.Printf("data:%s\n", string(jsonBytes))
// 转换结果
var memberInfoGetResponse response.MemberInfoGetResponse
response.ConvertResponse(jsonBytes, &memberInfoGetResponse)
if memberInfoGetResponse.IsSuccess() {
fmt.Printf("is_vip:%d, vip_endtime:%s\n", memberInfoGetResponse.MemberInfo.IsVip, memberInfoGetResponse.MemberInfo.VipEndtime)
} else {
fmt.Printf("code:%s, msg:%s, subCode:%s, subMsg:%s\n",
memberInfoGetResponse.Code, memberInfoGetResponse.Msg, memberInfoGetResponse.SubCode, memberInfoGetResponse.SubMsg)
}
}
```