Public platform development public platform developer public platform development mode weekly public solution interface API
1. obtain data
Fang times studio has developed an API for querying Zhou Gongjie dream. You are welcome to try it out.
The method is to directly submit the content name in the URL. the name must be urlencode first.
Call the url method: The following is a call to the Zhou Gongjie Meng method. the submitted content is "food"
http://api2.sinaapp.com/search/dream/?appkey=0020130430&appsecert=fa6095e113cd28fd&reqtype=text&keyword=%e9%a3%9f%e7%89%a9
The returned format is as follows:
{"Errcode": 0, "msgtype": "text", "text": {"content": "If you dream about a large amount of food, you will be discouraged. Dreaming that there is no food, it will make a lot of money. Women dream of a large amount of food, and the economy will be tight. "}}
A complete request is similar to the following:
If (substr ($ keyword,) = "dream") {$ entityName = trim (substr ($ keyword, 6, strlen ($ keyword ))); if ($ entityName = "") {$ contentStr = "Send" dream "with content, such as" Dream of first love ""; $ resultStr = $ this-> transmitText ($ object, $ contentStr, $ funcFlag); return $ resultStr ;}$ apihost = "http://api2.sinaapp.com /"; $ apimethod = "search/dream /? "; $ Apiparams = array ('appkey' =>" 0020130430 ", 'appcert' =>" fa6095e113cd28fd ", 'reqtype' =>" text "); $ apikeyword = "& keyword = ". urlencode ($ entityName); $ apicallurl = $ apihost. $ apimethod. http_build_query ($ apiparams ). $ apikeyword; $ api2str = file_get_contents ($ apicallurl); $ api2json = json_decode ($ api2str, true); $ contentStr = $ api2json ['text'] ['content']; $ resultStr = $ this-> transmitText ($ object, $ contentStr, $ funcFlag); return $ resultStr ;}
For the remaining code, see other articles in this blog. Http://www.cnblogs.com/txw1958/
2. Effect demonstration
III. trial account