首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何处理API响应

如何处理API响应
EN

Stack Overflow用户
提问于 2017-03-29 18:45:42
回答 1查看 320关注 0票数 4

我能够连接到心身 api并运行一个简单的命令来获取所有客户端数据。

代码语言:javascript
运行
复制
from Helper.ClientService import ClientServiceCalls

calls = ClientServiceCalls()
clients = calls.GetAllClients()
print(clients)

服务器将响应以下信息:

代码语言:javascript
运行
复制
(GetClientsResult){
   Status = "Success"
   ErrorCode = 200
   XMLDetail = "Full"
   ResultCount = 4503
   CurrentPageIndex = 0
   TotalPageCount = 181
   Clients = 
      (ArrayOfClient){
         Client[] = 
            (Client){
               MobileProvider = None
               AppointmentGenderPreference = "None"
               Gender = "Female"
               IsCompany = False
               LiabilityRelease = False
               PromotionalEmailOptIn = True
               CreationDate = 2017-02-23 00:00:00
               Liability = 
                  (Liability){
                     IsReleased = False
                     AgreementDate = None
                     ReleasedBy = None
                  }
               UniqueID = 100015484
               ID = "100015484"
               FirstName = "Sdfoij"
               LastName = "[asodfj"
               EmailOptIn = True
               State = "CA"
               Country = "US"
               BirthDate = None
               FirstAppointmentDate = 2017-03-03 00:00:00
               HomeLocation = 
                  (Location){
                     SiteID = -99
                     BusinessDescription = ""The MINDBODY Health Club Demo is awesome." - Anonymous (but probably someone cool and smart)"
                     AdditionalImageURLs = ""
                     FacilitySquareFeet = None
                     TreatmentRooms = None
                     HasClasses = True
                     PhoneExtension = None
                     ID = 1
                     Name = "Clubville"
                  }
               PhotoURL = "https://clients.mindbodyonline.com/studios/DemoAPISandboxRestore/clients/100015484_large.jpg?v=98"
               IsProspect = False
               Status = "Active"
               ContactMethod = 1
            }.... **and continue printing other client informations**

     }
 }

现在的问题是我想从中提取这些信息,

代码语言:javascript
运行
复制
Client Email, Client Name, Client Phone Number, Client Status (active or inactive), Client Birthday, Client Address, Most Recent Visit Date, Most Recent Visit Description, Start Date, Custom Field(s)

但是我不知道我能用什么库来解析这个输出,我在想美丽汤,但我不太确定,

我在使用apis方面真的是新手,所以如果有人能给我一个关于如何做到这一点的想法,那就太棒了。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-29 19:32:12

好的,我在googs中搜索了mindbody,并获得了以下链接:5/SiteService.asmx?wsdl。从API示例中的代码来看,它们显然是在使用SOAP。我的建议是,你可以尝试以下几点:

代码语言:javascript
运行
复制
from suds.client import Client
from Helper.ClientService import ClientServiceMethods
calls = ClientServiceMethods()
clients = calls.GetAllClients()
client_dict = Client.dict(clients)

或者看一下这个链接,因为它接收了一个响应,并将它转换成了一个数据集。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43101703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档