es
parent
3d6245d999
commit
bb0973b403
@ -0,0 +1,26 @@ |
||||
<?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'] ?? ''; |
||||
} |
||||
} |
Loading…
Reference in new issue