接入流程如下,需要先注册开发者帐号,之后会得到一个32位的key,保存下来,用于以后发送数据。http://www.tuling123.com/
请求方式
示例:
# -*- coding: utf-8 -*- import urllib import json def getHtml(url): page = urllib.urlopen(url) html = page.read() return html if __name__ == '__main__': key = '8b005db5f57556fb96dfd98fbccfab84' api = 'http://www.tuling123.com/openapi/api?key=' + key + '&info=' while True: info = raw_input('我: ') request = api + info response = getHtml(request) dic_json = json.loads(response) print '机器人: '.decode('utf-8') + dic_json['text']
原文地址:http://blog.csdn.net/aspnet_lyc/article/details/40477883