Class: Wechat::ShakeAround::Shaking

Inherits:
Object
  • Object
show all
Extended by:
Core::Common, Common
Defined in:
lib/wechat/shake_around/shaking.rb

Overview

微信摇一摇周边的摇动封装类。

Constant Summary

Constants included from Common

Common::ERROR_CODES

Class Method Summary collapse

Methods included from Common

normalize_date, normalize_device_id, normalize_page_ids

Class Method Details

.load(access_token, ticket) ⇒ Object

获取摇周边的设备及用户信息 mp.weixin.qq.com/wiki/3/34904a5db3d0ec7bb5306335b8da1faf.html

Return hash format if success: {

data:
{
  page_id: <PAGE_ID>,
  openid:  <OPEN_ID>,
  poi_id:  <POI_ID>,
  beacon_info:
  {
    distance: <DISTANCE>,
    uuid:     <UUID>,
    major:    <MAJOR>,
    minor:    <MINOR>
  }
},
errcode: 0,
errmsg:  'success.'

}



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/wechat/shake_around/shaking.rb', line 31

def self.load(access_token, ticket)

  assert_present! :access_token, access_token
  assert_present! :ticket,       ticket

  post_json "https://api.weixin.qq.com/shakearound/user/getshakeinfo?access_token=#{access_token}", body:
    {
      ticket:   ticket,
      need_poi: 1
    }
end