获取x-sign/x-mini-wua/x-sgext/x-umt

2021/5/23 18:27:25

本文主要是介绍获取x-sign/x-mini-wua/x-sgext/x-umt,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

文章目录

  • 获取x-sign/x-mini-wua/x-sgext/x-umt
    • 获取应用上下文
    • 获取Mtop
    • 获取MtopConfig
    • 从MtopConfig获得sign对象
    • 创建参数并调用

获取x-sign/x-mini-wua/x-sgext/x-umt

获取应用上下文

APP里有个Globals类,有静态方法可以获取应用上下文

var Globals = Java.use('com.taobao.tao.Globals')
var context = Globals.getApplication().getApplicationContext()
console.log(context)

获取Mtop

通过instance方法获取单例

// 获取 Mtop
var Mtop = Java.use('mtopsdk.mtop.intf.Mtop')
var mtop = Mtop.instance(context)
console.log(mtop)

获取MtopConfig

// 获取MtopConfig
var mtopConfig = mtop.getMtopConfig()

从MtopConfig获得sign对象

sign就是生成x-sign的对象

字段需要反射获取,如:‘mtopConfig.sign’ 是错误的

// 从MtopConfig获得sign对象
var signField = mtopConfig.class.getDeclaredField('sign')
console.log('signField:' + signField)
var sign = signField.get(mtopConfig)
console.log('sign:' + sign)

创建参数并调用

// 转换tb.nls类,否则找不到nls类的成员
var NLS = Java.use('tb.nls')
sign = Java.cast(sign, NLS)
console.log('methods:' + sign.class.getDeclaredMethods())

// 创建HashMap
var HashMap = Java.use('java.util.HashMap')
var map1 = HashMap.$new()
map1.put('uid', null)
map1.put('data', '{"contentId":"282546219508","frontModuleName":"recommendContent","params":"{\\"yhhListContentId\\":\\"282546219508\\",\\"business_spm\\":\\"a2141.12288619\\"}","source":"youhh_tuji","type":"weex"}')
map1.put('api', 'mtop.taobao.beehive.detail.contentrecommendservice')
map1.put('t', '1620649465')
map1.put('sid', null)
map1.put('v', '1.0')
map1.put('ttid', '703304@taobao_android_9.23.0')
map1.put('x-features', '1051')
map1.put('utdid', 'xxx')
map1.put('extdata', 'openappkey=DEFAULT_AUTH')
map1.put('appKey', '21646297')
map1.put('deviceId', 'xxx')
var map2 = HashMap.$new()
map2.put('pageName', 'https://market.m.taobao.com/apps/market/content/index.html')
map2.put('pageId', 'https://market.m.taobao.com/apps/market/content/index.html?contentId=282546219508&scm=1007.11419.220765.0&wh_weex=true&wx_navbar_transparent=true&business_spm=a2141.12288619&source=youhh_tuji&params=%7B%22yhhListContentId%22%3A%22282546219508%22%7D&utparam=%7B%22x_object_type%22%3A%22item_yhh_content%22%2C%22x_item_ids%22%3A626248537183%2C%22x_ad%22%3A1%2C%22x_object_id%22%3A%22282546219508%22%2C%22tpp_buckets%22%3A%221419%230%23220765%230%22%7D&utLogMap=%7B%22x_object_type%22%3A%22item_yhh_content%22%2C%22x_item_ids%22%3A626248537183%2C%22x_ad%22%3A1%2C%22x_object_id%22%3A%22282546219508%22%2C%22tpp_buckets%22%3A%221419%230%23220765%230%22%7D&spm=a2141.7631544.t0.p0&_wx_f_=1')
var result = sign.a(map1, map2, '21646297', null, false, 'r_17')
console.log(result)


这篇关于获取x-sign/x-mini-wua/x-sgext/x-umt的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程