In this system tutorial, the weather god account WeatherGod is used on the public platform to support the names, pinyin, area codes, voice triggering modes, geographic location queries, and image recognition of Weather Forecasts in Nearly 2500 cities in China, speech Recognition (research), stock query, express delivery query, date query, Constellation query, etc.) is used as an example to explain the interface development process. You are welcome to pay attention to this account.
In this system tutorial, the weather god account WeatherGod is used on the public platform to support the names, pinyin, area codes, voice triggering modes, geographic location queries, and image recognition of Weather Forecasts in Nearly 2500 cities in China, speech Recognition (research), stock query, express delivery query, date query, Constellation query, etc.) is used as an example to explain the interface development process. You are welcome to pay attention to this account and use various methods to query the local weather. for the QR code, see the bottom. |
I. request data
First, you must have an interface to obtain stock data. Fang times studio provides the following interface for stock query, of which 000063 is the ZTE stock code.
http://api2.sinaapp.com/search/stock/?appkey=0020130430&appsecert=fa6095e113cd28fd&reqtype=text&keyword=000063
The returned format is as follows:
{"Errcode": "0", "msgtype": "text", "text": {"content": "ZTE [000063] \ n latest: 12.42 \ n increase: 0.49 \ n increase: 4.11% \ n total number of hands: 0.476913 million \ n amount: 582.55 million \ n "}}
The core code for initiating a request is as follows:
$url = "http://api2.sinaapp.com/search/stock/?appkey=0020130430&appsecert=fa6095e113cd28fd&reqtype=text&keyword=".$keyword; $stockJson = file_get_contents($url); $stockInfo = json_decode($stockJson, true); $contentStr = $stockInfo['text']['content'];
2. Effect demonstration
Currently, domestic stock indexes are supported.Shanghai stock index, Shenzhen index, Shanghai and Shenzhen 300, SME Index, growth Enterprise Index, and B Share Index,The corresponding stock code (Tongda credit market code) is as follows:
Shanghai stock index 999999
Shenzhen index 399001
Shanghai and Shenzhen 300 000300
Medium and small Board refers to 399005
Growth Enterprise Market 399006
B shares index 000003
Stocks currently supportedShanghai A shares, Shanghai B shares, Shenzhen a shares, Shenzhen B shares, small and medium board, Growth Enterprise Market
The following is a queryShanghai stock index
Let's take a look at the prices of the Shanghai stock exchange index, which is exactly the same as the content.
Shenzhen index
The following is a queryShanghai A shares
Shenzhen B shares