npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cxtkapi

v0.1.5

Published

微信小程序版淘点金api对接模块

Downloads

11

Readme

微信小程序版淘客淘点金api对接模块

众所周知,微信是不允许连接淘宝的任何链接的。并且,微信小程序也不允许使用window对象下面的一些方法,所以淘宝官方提供的tkapi是无法在微信小程序里使用的。于是,便有了我们的CxTkapi模块。

| 方法名 | 类型 | 说明 |:--------|:--------:|:------------------------------------- | init | 实例方法 | 初始化,需提供pid、etProxy、referer | getLink | 实例方法 | 获取淘客链接 | clear | 静态方法 | 清除淘客身份信息缓存

安装

nodejs方式安装

npm install cxtkapi

bower方式安装

bower install cxtkapi

使用

注:使用该模块之前,我们得先有一台已注册到微信小程序里的合法https服务器。该服务器用于向淘宝请求etcode(我也不知道官方名叫什么,暂且这么叫)。其功能仅仅是代理请求:TKURL即可(:TKURL为内部用关键字,全大写,冒号不可省略)。

require方式

var CxTkapi = require('cxtkapi');
var tk = new CxTkapi;
tk.init({
    pid: 'mm_00000000_11111111_22222222', // 淘客pid
    etProxy: 'https://[yourhost]/?url=:TKURL', // 代理地址
    referer: 'https://[yourhost]/clothing/list.html' // 虚拟引用地址
});
// 获取淘客链接
tk.getLink('http://detail.tmall.com/item.htm?id=888888666666', function(url){
    console.log(url); // 输出淘客链接
});

引入方式

<script src="bower_components/cxtkapi/dist/cxtkapi.min.js"></script>
<script>
var tk = new CxTkapi;
tk.init({
    pid: 'mm_00000000_11111111_22222222', // 淘客pid
    etProxy: 'https://[yourhost]/?url=:TKURL', // 代理地址
    referer: 'https://[yourhost]/clothing/list.html' // 虚拟引用地址
});
// 获取淘客链接
tk.getLink('http://detail.tmall.com/item.htm?id=888888666666', function(url){
    console.log(url); // 输出淘客链接
});
</script>

清理

官方原版tkapi是把淘客的身份信息放到cookies里的,而微信小程序里我们使用的是storage。由于storage是不过期的,目前还不清楚不过期的身份信息会不会对淘客造成什么不良影响,所以建议使用完成后进行缓存清理。 建议的做法是放到微信小程序onLaunch阶段,这样每次启动都将获得一个新的身份信息。 示例如下:

App({
    onLaunch: function () {
        CxTkapi.clear(); // 清除淘客身份信息缓存
    }
})

更多

CxTkapi - github主页

issue