新版easywechat 获取手机号
/**
* 绑定手机号
* @param Request $request
* @return JsonResponse
* @throws TransportExceptionInterface
*/public function bindPhone(Request $request): JsonResponse
{
$code = $request->input('code');
$app = EasyWeChat::miniApp();
$data = $app->getClient()->postJson('wxa/business/getuserphonenumber', ['code' => $code]);
return $this->success($data);
}
我这样拿到的$data是个空对象 不知道哪里出了问题也不报错 是哪里写错了吗 还是没有配置
这个是获取手机号的,$app->phone_number->getUserPhoneNumber(string $code);
不过在使用前得初始化app
查看返回结果
var_dump($response->toArray());
easywechat.com/6.x/index.html