1. Go to this page and download the library: Download icharle/wxtool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
icharle / wxtool example snippets
php artisan vendor:publish --tag=wxtool
php artisan storage:link
namespace App\Http\Controllers;
use Icharle\Wxtool\Wxtool;
use Illuminate\Http\Request;
class TestController extends Controller
{
/**
* 获取带参数小程序码
* @param $scene 场景值(最大32个可见字符,只支持数字,大小写英文以及部分特殊字符)
* @param $pages 页面(必须是已经发布的小程序存在的页面(否则报错)
* @return $imgpath 小程序码路径 (可以直接访问 http://xxx.com/$imgpath)
*/
public function GetImgCode()
{
$a = new Wxtool();
$imgpath = $a->GetQrcode($scene,$pages);
}
}
namespace App\Http\Controllers;
use Icharle\Wxtool\Wxtool;
use Illuminate\Http\Request;
class TestController extends Controller
{
/**
* 获取用户详细信息
* @param Request $request
*/
public function GetInfo(Request $request)
{
$a = new Wxtool();
$code = $request->code; //wx.login获取
$encryptedData = $request->encryptedData; //wx.getUserInfo 获取
$iv = $request->iv; //wx.getUserInfo 获取
$res = $a->GetSessionKey($code); //获取用户openid 和 session_key
$userinfo = $a->GetUserInfo($encryptedData,$iv); //获取用户详细信息
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.