mirror of
https://gitee.com/zoujingli/WeChatDeveloper.git
synced 2025-04-06 03:58:03 +08:00
[更新]修改微信小程序二维码支持
This commit is contained in:
parent
9e6e0a9aec
commit
d0877f695a
@ -10,11 +10,12 @@ $config = [
|
||||
|
||||
$mini = new WeMini\Qrcode($config);
|
||||
|
||||
echo '<pre>';
|
||||
//echo '<pre>';
|
||||
try {
|
||||
// var_dump($mini->getCode('pages/index?query=1'));
|
||||
// var_dump($mini->getCodeUnlimit('432432', 'pages/index/index'));
|
||||
var_dump($mini->createQrcode('pages/index?query=1'));
|
||||
header('Content-type:image/jpeg');//输出的类型
|
||||
// echo $mini->createDefault('pages/index?query=1');
|
||||
// echo $mini->createMiniScene('432432', 'pages/index/index');
|
||||
echo $mini->createMiniPath('pages/index?query=1');
|
||||
} catch (Exception $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ class Qrcode extends BasicWeChat
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCode($path, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"])
|
||||
public function createMiniPath($path, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"])
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/getwxacode?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
@ -57,7 +57,7 @@ class Qrcode extends BasicWeChat
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function getCodeUnlimit($scene, $page, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"])
|
||||
public function createMiniScene($scene, $page, $width = 430, $auto_color = false, $line_color = ["r" => "0", "g" => "0", "b" => "0"])
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN';
|
||||
$data = ['scene' => $scene, 'width' => $width, 'auto_color' => $auto_color, 'page' => $page, 'line_color' => $line_color];
|
||||
@ -75,11 +75,11 @@ class Qrcode extends BasicWeChat
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
public function createQrcode($path, $width = 430)
|
||||
public function createDefault($path, $width = 430)
|
||||
{
|
||||
$url = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN';
|
||||
$this->registerApi($url, __FUNCTION__, func_get_args());
|
||||
$result = Tools::post($url, Tools::arr2json(['path' => urlencode($path), 'width' => $width]));
|
||||
$result = Tools::post($url, Tools::arr2json(['path' => $path, 'width' => $width]));
|
||||
return strlen($result) > 256 ? $result : Tools::json2arr($result);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user