WeChat public platform Message Interface Development (5) stock query

Source: Internet
Author: User
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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.