API to the Turing man. We all know that the public number can have automatic replies, we first write a simple auto-reply script with a Python script, using the Turing's human API.
Http://www.tuling123.com/help/h_cent_webapi.jhtml?nav=doc This is the data format of the interface provided by the API, with this we have to develop the public number of the automatic reply is very simple (self-expansion).
The code is as follows:
# coding=utf-8import json,urllibdef Zidonghuifu (content): Url= '/http Www.tuling123.com/openapi/api ' data={"key": "Your Key", "info": Content} data=urllib.urlencode (data) html=urllib . Urlopen (Url,data). Read () j=json.loads (HTML) code=j[' code '] if code = = 100000:recontent = j[' text '] El if code = = 200000:recontent = j[' text ']+j[' url '] elif code = = 302000:recontent = j[' text ']+j[' list '][0] [' article ']+j[' list '][0][' Detailurl '] elif code = = 308000:recontent = j[' text ']+j[' list '][0][' info ']+j[' list ' [ 0][' detailurl ' else:recontent = ' small robot has not learned how to reply to this sentence ' return recontentif __name__== ' __main__ ': print (' is starting. 。。。。 Print (' Quiz applet ') print (' Start complete. ') while True:content=raw_input (' Q: ') Me=zidonghuifu (content) print (Me)