Skip to content

Commit

Permalink
新增获取小程序 Short Link接口
Browse files Browse the repository at this point in the history
  • Loading branch information
hopegao committed Aug 17, 2023
1 parent 6b9dbf7 commit 06084cf
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/services/WxIsvUrllinkService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ interface UrllinkGenerateResult {
urlLink: string
}

interface ShortUrllinkGenerateResult {
link: string
}

export class WxIsvUrllinkService extends WxIsvServiceBase {
/**
* 生成永久的URL LINK
Expand Down Expand Up @@ -50,4 +54,23 @@ export class WxIsvUrllinkService extends WxIsvServiceBase {
access_token: accessToken,
})
}

/**
* 获取小程序 Short Link,适用于微信内拉起小程序的业务场景
* 详见 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/short-link/generateShortLink.html
*/
async generateShortLink(
accessToken: string,
page_url: string,
page_title = '',
is_permanent = true
): Promise<ShortUrllinkGenerateResult> {
return await this.request(
'POST',
'/wxa/genwxashortlink',
{},
{ access_token: accessToken, page_url, page_title, is_permanent }
)
}

}

0 comments on commit 06084cf

Please sign in to comment.