You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/common/library/wechat/ShortLink.php

26 lines
733 B

<?php
namespace app\common\library\wechat;
use app\common\library\helper;
class ShortLink extends WxBase
{
public function shortUrl($page_url, $page_title, $is_permanent = false)
{
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/wxa/genwxashortlink?access_token=$accessToken";
$data = [
'page_url' => $page_url,
'page_title' => $page_title,
'is_permanent' => $is_permanent,
];
$result = $this->post($url, helper::jsonEncode($data));
$response = $this->jsonDecode($result);
if (!empty($response['link'])) {
return $response['link'];
}
return $response['errmsg'] ?? '';
}
}