您当前的位置: 首页 > 

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

微信文章长连接转短连接

彭世瑜 发布时间:2020-07-27 10:53:35 ,浏览量:1

需要说明的是:

  1. 此方法是微信长连接转【短链接】,不是转永久连接
  2. 接口获得条件:订阅号无法开通此接口,【服务号】必须通过【微信认证】
第一步:获取ACCESS_TOKEN

先在微信公众号后台获取APPID和APPSECRET

通过接口获取ACCESS_TOKEN

GET https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET

文档: https://developers.weixin.qq.com/doc/offiaccount/Basic_Information/Get_access_token.html

第二步:长连接转短连接
POST https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN
content-type: application/json

{
    "action": "long2short",
    "long_url":"https://mp.weixin.qq.com/s/mcChCB3vRKmte5a1oP0qVQ"
}

返回结果

{
  "errcode": 0,
  "errmsg": "ok",
  "short_url": "https:\/\/w.url.cn\/s\/AE7X97r"
}

文档: https://developers.weixin.qq.com/doc/offiaccount/Account_Management/URL_Shortener.html

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.1139s