API Description

This API is used to create a red packet campaign, set basic information of campaign (validity period, switch, etc.), return campaign ID.

API Request Format

API request from server
HTTP request method: POST
URL: https://api.weixin.qq.com/shakearound/lottery/addlotteryinfo?access_token=ACCESSTOKEN&use_template=1&logo_url=LOGO_URL

Request Parameters

Parameter Type Description
access_token string accesstoken, which is appended to the URL as a parameter.
use_template int Indicates whether to use the template. 1: Yes; 2: No. (appended to the URL as a parameter). The template is the red packet loading page in the interaction flow. If a template is used, the red packets are opened automatically without being tapped by users. If no template is used, you need to develop the HTML5 page by yourself and invoke the red packet jsapi on the page.
logo_url string logo_url on the page using the template. It can be left empty if no template is used. This is the message icon on the "Shake" screen, with a dimension of 120x120 pixels.

POST BODY: Structured field in JSON format.

Parameter Type Description
title string Red packet campaign title, with a maximum length of 6 Chinese characters (12 English characters). If a template is used, it can be used as the title of the Shake message.
desc string Red packet campaign description, with a maximum length of 7 Chinese characters (14 English characters). If a template is used, it can be used as the subtitle of the Shake message.
onoff int Campaign switch. 0: off; 1: on. Default is 1.
begin_time long Campaign start time, expressed as a Unix timestamp (in sec).
expire_time long Campaign end time, expressed as a Unix timestamp (in sec). The maximum validity period of a campaign is 91 days.
sponsor_appid string Appid of the Official Account owned by the merchant who provides the red packets. This should be same as the Official Account ID appid (wxappid) specified when the Pre-Order API is called.
total long Total number of red packets, which should be greater than or equal to the total number of red packet tickets specified when the Pre-Order API is used.
jump_url string URL of the third-party's custom page to which a user is redirected from the red packet following page.
key string A developer-defined 32-digit key used to generate the signature parameter for the lucky draw API. For more information, see the "Signature Generation Rules".

Request Example

Content-Type: application/json Post Body:
{                                                          
"title": "title",                           
"desc": "desc",                             
"onoff": 1,                              
"begin_time": 1428854400,                          
"expire_time": 1428940800,                          
"sponsor_appid": "wxxxxxxxxxxxxxx",
"total": 10,
"jump_url": JUMP_URL,     
"key": "keyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"                          
}

Response

Parameter Type Description
errcode int Error code. 0 indicates a successful request, and any value other than 0 indicates a failed request. For more information, see the list of error codes.
errmsg string Error message
lottery_id string Generated red packet campaign ID
page_id int Generated template page ID

Example

{     
"errcode":0,     
"errmsg":"",     
"lottery_id":"xxxxxxllllll", 
"page_id":1, 
}