Shake to follow JSAPI


Shake and follow JSAPI

1475888789648994.jpg

Interface Description

The purpose of the Shake to Follow JS API is to provide the Shake to Follow capability for merchants who have opened WeChat Shake peripherals and have certain development capabilities. Merchants can directly call the shake-to-follow interface on the shake-out page to realize the function of following public accounts.

Notes:

1) When using shake to follow, do not induce User attention, once verified, the account will be banned;

2) can only run normally on the H5 page of the surroundings. If you open a web page directly in the WeChat browser, this interface cannot run. When debugging, developers must pay attention to the complete shaking process and enter the page test through shaking.

3) Follow the public account belonging to the store, which only takes effect within 1 kilometer of the store.

Data example

Focus on the JS API call format being consistent with WeChat’s JS API call format, as follows:

###
Public functionsinvoke
UseActively call the specified API
General formBeaconAddContactJsBridge.invoke ("API name", {call parameters}, <callback function>);
#

Note: All codes in the document can only run correctly in the WeChat shaking environment. When opening a web page directly in the WeChat browser, BeaconAddContactJsBridge will not run correctly. When debugging, developers must pay attention to the complete shaking process and enter the page test through shaking.

example:

<!DOCTYPEhtml>

<htmllang="en">

##<head>

        <metacharset="UTF- 8">

##           <title>Example for developers to call attention to JS</title>

</head>

##< body>

>test</h1>

<scripttype="text/javascript"src="http://zb.weixin.qq.com/nearbycgi/addcontact/BeaconAddContactJsBridge.js">

</script>

<scripttype="text/javascript">

       BeaconAddContactJsBridge.ready(function(){

              //判断是否关注

              BeaconAddContactJsBridge.invoke('checkAddContactStatus',{ type:0} ,function(apiResult){

                     if(apiResult.err_code == 0){

                            var status = apiResult.data;

                            if(status == 1){

                                   alert('已关注');

                                                                                                                                                                                                                                      through 'Not followed');

##                                                                 

# BeaconAddContactJsBridge.invoke('jumpAddContact',{ type:0});

unch ##

                            alert(apiResult.err_msg)

                     }

              });

 

       });

</script>

</body>

</html>


引入BeaconAddContactJsBridge

<scripttype="text/javascript"src="http://zb.weixin.qq.com/nearbycgi/addcontact/BeaconAddContactJsBridge.js">

</script>

API detailed description

(1) Determine whether to pay attention to checkAddContactStatus

a)Parameters: Passing in {type:0} means following the public account belonging to the device, passing in {type:1} means following the public account belonging to the store. Passing in { } defaults to passing in {type:0}.

b) Callback function: function(apiResult){}

apiResult.err_code: Error code, 0 means normal return, other means an error occurred.

apiResult.err_msg: Error details, "ok" means normal return, others represent specific error information.

apiResult.data: Whether to pay attention, 1 means you have paid attention, 0 means you have not paid attention.

Example:

##BeaconAddContactJsBridge.invoke ('checkAddContactStatus',{type:0} ,

function(apiResult }

## Var Status = Apiresult.data; ##

                                                                                                                                                                                                                                                                                              through ##'Already followed');##                                                                                         

# Alert (

not to follow ');} #} ## Else

# {# Alert (APIRESULT.ER_MSG) }

           });

(2) Jump to the follow page jumpAddContact

a)       Parameters: Passing in {type:0} means following the public account belonging to the device, passing in {type:1} means following the public account belonging to the store. If not passed, {type:0} is passed by default.

b) Callback function: None.

Example:

BeaconAddContactJsBridge.invoke('jumpAddContact');