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.

37 lines
1.4 KiB

<?php
namespace LaneWeChat\Core;
class Popularize{
public static function createTicket($type, $expireSeconds, $sceneId){
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='.AccessToken::getAccessToken();
$queryAction = 'POST';
$template = array();
if($type == 1){
$template['expire_seconds'] = $expireSeconds;
$template['action_name'] = 'QR_SCENE';
}else{
$template['action_name'] = 'QR_LIMIT_SCENE';
}
$template['action_info']['scene']['scene_id'] = $sceneId;
$template = json_encode($template);
return Curl::callWebServer($queryUrl, $template, $queryAction);
}
public static function getQrcode($ticket, $filename=''){
$queryUrl = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.urlencode($ticket);
$queryAction = 'GET';
$result = Curl::callWebServer($queryUrl, '', $queryAction, 0);
if(!empty($filename)){
file_put_contents($filename, $result);
}
return $result;
}
public static function long2short($longUrl){
$queryUrl = 'https://api.weixin.qq.com/cgi-bin/shorturl?access_token='.AccessToken::getAccessToken();
$queryAction = 'POST';
$template = array();
$template['long_url'] = $longUrl;
$template['action'] = 'long2short';
return Curl::callWebServer($queryUrl, '', $queryAction);
}
}