# Get the sdk temporary ticket
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface English name: getTicket
The api_ticket is a temporary ticket used to invoke the js-sdk, valid for 7200 seconds, and is obtained by access_token.
# 1. How to call
# HTTPS calls
GET https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=TYPE
# Cloud Calls
- This interface does not support cloud calls
# Third party invocation
- Third Party Platform calls are not supported by this interface.
# 2. Request parameters
# Query parametersQuery String parameters
Parameter Name | type | Required to fill in | Example | Introductions |
---|---|---|---|---|
access_token | string | yes | - | Interface invocation credentials, using access_token , authorizer_access_token |
type | string | yes | jsapi | Ticket type, jsapi is js-sdk certificate;The wx_card is a WeChat card voucher |
# Request BodyRequest Payload
nothing
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
ticket | string | Temporary instruments |
expires_in | number | Validity period (seconds) |
errcode | number | Error code |
errmsg | string | Error message |
# 4. Note
Because the number of API calls to get API_ticket is very limited, frequent refreshing API_ticket will lead to limited API calls, affecting their own business, developers need to store and update API_ticket in their own services.
# 5. Code examples
Example Requests
https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=wx_card
Return an example
{
"errcode":0,
"errmsg":"ok",
"ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKdvsdshFKA",
"expires_in":7200
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
-1 | system error | The system is busy, so the developer is asked to try again in a few minutes. |
40001 | invalid credential access_token isinvalid or not latest | AppSecret error while getting access_token, or access_token is invalid.Developers should check that AppSecret is correct, or that they are calling interfaces for the appropriate Official Account |
# 7. Scope of application
How this interface can be invoked under different account types:
Official Account | Service Account | Mobile App | Website App |
---|---|---|---|
✔ | ✔ | ✔ | ✔ |
- ✔: The account can call this interface
- Other account types that are not expressly stated may not be called on this interface without special instructions;