新版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是个空对象 不知道哪里出了问题也不报错 是哪里写错了吗 还是没有配置

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 7

这个是获取手机号的,$app->phone_number->getUserPhoneNumber(string $code);
不过在使用前得初始化app

use EasyWeChat\Factory;

$config = [
    'app_id' => 'xxxx',
    'secret' => 'xxxx',

    // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
    'response_type' => 'array',

    //...
];

$app = Factory::officialAccount($config);
2年前 评论
周小云 (楼主) 2年前
cccyzloong (作者) 2年前
cccyzloong (作者) 2年前
周小云 (楼主) 2年前

查看返回结果

var_dump($response->toArray());

2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!