12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\common\util\wechat;
- use app\common\util\SingleObjectClass;
- use EasyWeChat\Factory;
- use think\Log;
- /**
- * 微信小程序实例化对象
- * Class MiniProgramSDK
- * @package app\common\util
- */
- class MiniProgramSDK extends SingleObjectClass
- {
- protected $app;
- /**
- * 构造函数
- * MiniProgramSDK constructor.
- */
- public function __construct()
- {
- $miniProgramConfig = WxAccountConfig::getMiniProgramConfig();//获取小程序配置
- $this->app = Factory::miniProgram($miniProgramConfig);
- $cache = new WechatCache();
- $this->app->rebind('cache', $cache);
- Log::record($cache);
- }
- /**
- * 获取小程序接口实例
- * @return \EasyWeChat\MiniProgram\Application
- */
- public function getApp()
- {
- return $this->app;
- }
- public function getPhoneNumber($code){
- $params = [
- 'code' => $code
- ];
- return $this->app->live->httpPostJson('wxa/business/getuserphonenumber', $params);
- }
- }
|