WeChat session control


Session Control

201610171124143832.png

##Create Session


This interface creates a session between the customer service and the user. If the customer service and user session already exist, 0 will be returned directly. The designated customer service account must be bound to WeChat ID and online.

Calling instructions

Parameter description
1
2
3
4
5
6
7
##http request method: POST
https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN
POST data examples are as follows:
{
"kf_account" : "test1 @test",
"openid" : "OPENID"
}


##ParameterDescriptionkf_accountComplete customer service account, the format is: account prefix@public account WeChat IDopenidfans The openidreturn description


##12
3
4
5
Return data example (JSON return result when correct):
{
"errcode"
: 0,
"errmsg"
: "ok"
}


Close session

Call instructions

1
2
3
4
5
6
7
http request Method: POST
https://api.weixin.qq.com/customservice/kfsession/close?access_token=ACCESS_TOKEN
POST data example is as follows:
{
     "kf_account" : "test1@test",
        "openid" : "OPENID"
}

Parameter description

ParameterDescription
kf_accountComplete customer service account, the format is: account prefix@public account WeChat ID
openidFan’s openid

Return instructions

1
2
3
4
5
Return data example (JSON return result when correct):
{
##"errcode" : 0,
"errmsg" : "ok"
}
Main return code


Return codeDescription0Success65400API is not available, that is, the new version of customer service function has not been activated/upgraded65401Invalid customer service account65402The account has not been bound to WeChat ID and cannot be put into use 65413There is no session information corresponding to the user65414The customer is being serviced by another customer service Reception40003illegal openid

Get customer session status

This interface gets a customer's session. If it does not exist, kf_account is empty.

Calling instructions

1
2
http request method: GET
##https://api.weixin.qq.com/customservice/kfsession/getsession?access_token=ACCESS_TOKEN&openid=OPENID
Parameter description


ParameterDescriptionopenidfan’s openid

Return instructions

12345 Return data example (JSON return result when correct): { "createtime" : 123456789, "kf_account" : "test1@test" } Parameter description Parameter description kf_account Customer service being received , empty means no one is receiving createtime session access time. Main return code Return code description 0 Success 65400 API is not available, that is, it is not activated/upgraded to the new version of customer service function 40003 Illegal openid Get customer service session list Call description 12 http request method: GEThttps://api.weixin.qq.com/customservice/kfsession/getsessionlist?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT Parameter description Parameter description kf_account complete customer service account, the format is: account prefix @ official account WeChat ID returns saying
1
2
3
4
5
6
7
8
9
10
11
12
13
Return data example (JSON return result when correct):
{
       "sessionlist" : [
                                                                                                                                                                                                              #:
"OPENID"
##         },
##                                                
                                                                                                                                                                                                                                                                          through " : "OPENID"
         }
       ]
}
Get unconnected session ListCall description
##1
2
http request method: GEThttps://api.weixin.qq.com/customservice/kfsession/getwaitcase?access_token=ACCESS_TOKEN

Return description

count
1
2
3
4
5
6
7
8
9
10
11
12
13
14
## Return data example (JSON return result when correct):
{
"count" : 150,
      "waitcaselist" : [
##            
{
       
"latest_time" : 123456789,##                                                                                   
"OPENID"##           },##                                                
"Latest_time"
##: 123456789,
## "Openid"
:
"OPENID"
}
]
}
Parameter Description
ParametersDescription

Number of unconnected sessions

waitcaselistopenidlatest_time

Return code description

Not connected to the session list, a maximum of 100 pieces of data will be returned, in the order of visits
Fans’ openid
The time of the fan’s last message
##40003Illegal openid
Return codeDescription
0Success
65400API is not available, that is, it has not been activated or upgraded to the new version of customer service function
65401Invalid customer service account
65402The customer service account has not been bound to WeChat ID and cannot be put into use
65413 There is no session information corresponding to the user
65414Fans are being received by other customer service
65415The specified customer service is not online