<?php
namespace WeMini;
use WeChat\Contracts\BasicWeChat;
use WeChat\Contracts\Tools;
class Code extends BasicWeChat
{
public function commit($templateId, $extJson, $userVersion, $userDesc)
{
$url = 'https://api.weixin.qq.com/wxa/commit?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
$data = [
'template_id' => $templateId,
'ext_json' => $extJson,
'user_version' => $userVersion,
'user_desc' => $userDesc,
];
return $this->httpPostForJson($url, $data, true);
}
public function getQrcode($path = null, $outType = null)
{
$pathStr = is_null($path) ? '' : ("&path=" . urlencode($path));
$url = "https://api.weixin.qq.com/wxa/get_qrcode?access_token=ACCESS_TOKEN{$pathStr}";
$this->registerApi($url, __FUNCTION__, func_get_args());
$result = Tools::get($url);
if (json_decode($result)) {
return Tools::json2arr($result);
}
return is_null($outType) ? $result : $outType($result);
}
public function getCategory()
{
$url = 'https://api.weixin.qq.com/wxa/get_category?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function getPage()
{
$url = 'https://api.weixin.qq.com/wxa/get_page?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function submitAudit(array $itemList)
{
$url = 'https://api.weixin.qq.com/wxa/submit_audit?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['item_list' => $itemList], true);
}
public function getNotify()
{
return Tools::xml2arr(file_get_contents('php://input'));
}
public function getAuditstatus($auditid)
{
$url = 'https://api.weixin.qq.com/wxa/get_auditstatus?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['auditid' => $auditid], true);
}
public function getLatestAuditatus()
{
$url = 'https://api.weixin.qq.com/wxa/get_latest_auditstatus?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function publishRelease()
{
$url = 'https://api.weixin.qq.com/wxa/release?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, [], true);
}
public function changeVisitStatus($action)
{
$url = 'https://api.weixin.qq.com/wxa/change_visitstatus?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['action' => $action], true);
}
public function revertCodeRelease()
{
$url = 'https://api.weixin.qq.com/wxa/revertcoderelease?access_token=TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function getWeappSupportVersion()
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/getweappsupportversion?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, []);
}
public function setWeappSupportVersion($version)
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/setweappsupportversion?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['version' => $version]);
}
public function addQrcodeJump(array $data)
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpadd?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
public function getQrcodeJump(array $data)
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpget?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, $data);
}
public function downloadQrcodeJump()
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdownload?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, []);
}
public function deleteQrcodeJump($prefix)
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumpdelete?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['prefix' => $prefix]);
}
public function publishQrcodeJump($prefix)
{
$url = 'https://api.weixin.qq.com/cgi-bin/wxopen/qrcodejumppublish?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['prefix' => $prefix]);
}
public function undoCodeAudit()
{
$url = 'https://api.weixin.qq.com/wxa/undocodeaudit?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function grayRelease($gray_percentage)
{
$url = 'https://api.weixin.qq.com/wxa/grayrelease?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpPostForJson($url, ['gray_percentage' => $gray_percentage]);
}
public function revertGrayRelease()
{
$url = 'https://api.weixin.qq.com/wxa/revertgrayrelease?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
public function getGrayreLeasePlan()
{
$url = 'https://api.weixin.qq.com/wxa/getgrayreleaseplan?access_token=ACCESS_TOKEN';
$this->registerApi($url, __FUNCTION__, func_get_args());
return $this->httpGetForJson($url);
}
}