php微信企业号获取用户userid
<?php
if($_GET['code']){
$corpid = "wx690e2a9380e2440dyt";
$secrect = "3g9l6dHy8qjYqYMWX44ZeTsJkgUCEFioZ6Ti0iu1oWPxbnjvFQZPKsMi2b+QYltTyt";
$access_key = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={$corpid}&corpsecret={$secrect}";
$result = file_get_contents($access_key);
$access_token_array = json_decode($result,true);
$access_token = $access_token_array['access_token'];
$code = $_GET['code'];
$url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={$access_token}&code={$code}";
$result_userinfo = file_get_contents($url);
var_dump($result_userinfo);
exit;
}else{
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx690e2a9380e2440dyt&redirect_uri=http://wx.75271.com/weixinqiye.php&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
header('Location: '.$url);
}