现在我在python应用程序中使用octranspoapi(http://www.octranspo1.com/developers/documentation)。在
对于我请求他们的API检索数据,我有这个
class OcTranspoGetter:
#import credentials from file, my credentials are not in sample file,
#they can be gotten from http://www.octranspo1.com/developers/
def __init__(self):
credFile = open('../config/logins.ser')
credentials = pickle.load(credFile)
self.apiID = credentials['apiLogin']['apiID']
#self.apiKey = credentials['apiLogin']['apiKey']
self.payLoad = {'apiID':self.apiID,'apiKey':self.apiKey}
print self.payLoad
#Get live data
def getLiveData(self,bus,stop):
self.payLoad['stopNum'] = stop
soapData = requests.post('https://api.octranspo1.com/v1.2/GetRouteSummaryForStop',data = self.payLoad)
return soapData
但是当我运行代码时:
^{pr2}$我得到错误:应用程序带有 id="" was not found
从这个和从soapData返回的url来看,如下所示请求.post()仍在使用get方法请求API。该服务需要post,正如上面的文档所说要使用curl-d命令。从我所看到的请求文档(http://docs.python-requests.org/en/latest/user/quickstart)来看,我正在做的应该是一个post请求,但它不是。文件里有没有我遗漏的东西?在
根据文档,第一个参数应该是}。在
appID
,而不是{相关问题 更多 >
编程相关推荐