我想知道Intersango API(文档记录不完整)的正确URL格式。我在C#编程我的客户,但我看Python example和我有点困惑,什么是真正被放置在请求主体:如何向Intersango API发送请求
def make_request(self,call_name,params):
params.append(('api_key',self.api_key)) // <-- How does this get serialized?
body = urllib.urlencode(params)
self.connect()
try:
self.connection.putrequest('POST','/api/authenticated/v'+self.version+'/'+call_name+'.php')
self.connection.putheader('Connection','Keep-Alive')
self.connection.putheader('Keep-Alive','30')
self.connection.putheader('Content-type','application/x-www-form-urlencoded')
self.connection.putheader('Content-length',len(body))
self.connection.endheaders()
self.connection.send(body)
response = self.connection.getresponse()
return json.load(response)
//...
我想不通出这段代码:params.append(('api_key',self.api_key))
它是某种字典,它被序列化为JSON,逗号分隔或者它是如何被序列化的?当参数被编码并分配给它时,身体会是什么样子?
P.S.我没有任何可以运行代码的东西,所以我可以调试它,但是我只是希望这足够简单,可以理解知道Python的人,并且他们能够告诉我该线路上发生了什么的代码。
你能够使它发挥作用?我遵循相同的步骤,但根本无法获得经过身份验证的API工作,得到{“远程服务器返回错误:(417)期望失败。”} – galets 2012-06-20 04:01:55