Laravel easyWechat微信composer

1. composer https://packagist.org/packages/overtrue/wechat

2.官方文档 https://www.easywechat.com/docs/4.1/troubleshooting#heading-h2-2

 

 


1.通过wx_code,直接获取openid

use EasyWeChat\Factory;


public
function demo() { $config = [ 'app_id' => 'wxb7529904a4b39e54', 'secret' => 'dad224d0a0be6f4bcc936da7359495x2b', // 下面为可选项 // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 'response_type' => 'array', 'log' => [ 'level' => 'debug', 'file' => __DIR__.'/wechat.log', ], ]; // print_r($config);exit; $app = Factory::miniProgram($config); $code = "0536sOkl2Hx8x54bUqml2v1Tpx16sOk4"; $a = $app->auth->session($code); print_r($a);exit; }

 

 

 

Array
(
    [session_key] => rRNzkdJtFMsumpxSSOmuNeg==
    [openid] => oxBm9I4w-Ar8xUXKT4Z-hihVxhpFk
)

 

posted @ 2020-08-31 14:29  林间有风-邓  阅读(528)  评论(0编辑  收藏  举报