It's easy to call (send an HTTP request to) the Weixin Open Platform semantic understanding API. You do not need to know anything about semantic understanding or the relevant technical details. You can simply select the relevant services based on your business features to build a smart semantic service.

# Step 1: Create an app

Go to the "Management Center", click "Create Mobile App" or "Create Website App", and fill in the relevant information. Then, submit this app for review. Development can start after the app is approved.

After you have finished the registration process, we will complete the review within seven business days. After the app is approved, the Open Platform will allocate a globally unique AppID and AppSecret to the mobile app.

# Step 2: Obtain an access token based on the AppID and AppSecret

# Call the API:
HTTP request method: GET
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
# Parameters
Parameter Required Description
grant_type Yes Enter client_credential to get access_token
appid Yes The app's AppID.
secret Yes The app's AppSecret.
# Response description:

For a successful request, Weixin returns the following JSON packet:

{
"access_token":"ACCESS_TOKEN",
"expires_in":7200
}
Parameter Description
access_token The obtained credential
expires_in The time when the credential expires (in sec)

When an error occurs, Weixin will return an error code and related information. An example of the JSON packet (for an invalid AppID error) is shown below:

{
"errcode":40013,
"errmsg":"invalid appid"
}

# Step 3: Use the access token to call the semantic understanding API

# Information entry instructions:
HTTP request method: POST (HTTPS protocol should be used)
https://api.weixin.qq.com/semantic/semproxy/search?access_token=YOUR_ACCESS_TOKEN
POST data format: JSON
POST data example:
{
"query":"Query China Southern Airlines tickets from Beijing to Shanghai tomorrow",
"city":"Beijing",
"category": "flight,hotel",
"appid":"wxaaaaaaaaaaaaaaaa",
"uid":"123456"
}
# Parameter entry instructions:
Parameter Required Type Description
access_token Yes String The token obtained based on the AppID and AppSecret
query Yes String Enter a text string
category Yes String Service type. Separate multiple types with commas (,). This parameter can be left blank.
latitude See the API protocol documentation. Float Latitude coordinates, provided with longitude coordinates at the same time. This parameter is not required if "city" is specified.
longitude See the API protocol documentation. Float Longitude coordinates, provided with latitude coordinates at the same time. This parameter is not required if "city" is specified.
city See the API protocol documentation. String City name. This parameter is not required if "latitude" and "longitude" are specified.
region See the API protocol documentation. String Region name. This parameter is not required if "city" or "latitude" and "longitude" are specified.
appid Yes String The AppID that uniquely identifies the developer
uid No String The unique ID of the user (not the developer). This is used to distinguish between users in the app (we recommend using the user's openid). If this field is left blank, you cannot use the context understanding feature, because this requires both the AppID and UID.
# Response description:

For a successful request, Weixin returns the following JSON packet:

{
	"errcode":0,
	"query":"Query China Southern Airlines tickets from Beijing to Shanghai tomorrow",
	"type":"flight",
	"semantic":{
		"details":{
			"start_loc":{
			"type":"LOC_CITY",
Beijing
			"city_simple":"Beijing",
			"loc_ori":"Beijing"
			},
			"end_loc": {
			"type":"LOC_CITY",
			"city":"Shanghai City",
			"city_simple":"Shanghai",
			"loc_ori":"Shanghai"
			},
			"start_date": {
			"type":"DT_ORI",
			"date":"2014-03-05",
			"date_ori":"Tomorrow"
			},
			"airline":"China Southern Airlines"
		},
		"intent":"SEARCH"
	}
}

# Response parameters:

Parameter Required Type Description
errcode Yes Int Indicates the request status
query Yes String The string entered by the user
type Yes String The global type ID of the service. See the definition of the vertical service protocol in the protocol documentation.
semantic Yes Object The structured identifier after semantic understanding (different for each service)
result No Array The results for some categories
answer No String The results for some categories displayed in HTML5 (currently unsupported)
text No String Special reply instructions

For more detailed information and protocol description, see Semantic Understanding API Protocol Documentation.