PHP code example of xzncit / developer-tools
1. Go to this page and download the library: Download xzncit/developer-tools 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/ */
xzncit / developer-tools example snippets
use xzncit\Factory;
try {
// wechat
$app = Factory::Wechat([
"token"=>"omJNpZEhZ5VFbk1HeHj1ZxFECKkP48BP",
"appid"=>"wxa02e77d8a507d608",
"appsecret"=>"3396f50c1f55c2089f4316b6f7c9f71b"
]);
// 创建自定义菜单
$response = $app->menu->create([
// ...
]);
// 返回信息
var_dump($response);
}catch (\Exception $ex){
echo("error: ".$ex->getMessage());
}
try {
// mini
$app = Factory::MiniProgram([
"appid"=>"wxa02e77d8a507d608",
"appsecret"=>"3396f50c1f55c2089f4316b6f7c9f71b"
]);
// 登录凭证校验
$response = $app->oauth->code2Session("31f55c2089f4316b6");
// 返回信息
var_dump($response);
}catch (\Exception $ex){
echo("error: ".$ex->getMessage());
}