微信获取用户的信息,哭哭弄不出来了

就是运行不出来嘤嘤嘤,求大佬帮助~

<?php
header("content-type:text/html;charset=utf-8");
$appid='.....';
$appsecret='.....';

$access_token=get_access_token($appid,$appsecret);
$next_openid="";
$user=user_query($access_token,$next_openid);
show_users($user);
function show_users($user)
{
if(empty($user))
return ;
echo "用户总数:" . $user->total . "
";
echo "本次获取用户数:" . $user->count . "
";
$users=$user->data->openid;
foreach ($users as $v)
{
echo $v . "
";
}
}
function get_access_token($appid,$appsecret)
{
$url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$output=curl_exec($ch);
if(curl_errno($ch))
{
echo 'Errno' .curl_error($ch);
}
curl_close($ch);
$jsoninfo=json_decode($output,true);
return $jsoninfo["access_token"];
}
function user_query($access_token,$next_openid)
{
$url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=$access_token&next_openid=$next_openid";

$ch=curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_NOBODY,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$result=curl_exec($ch);
if(curl_errno($ch))
{
    echo 'Errno' .curl_error($ch);
}
curl_close($ch);
$data=json_decode($result);
if(!empty($data->errcode))
{
    return "";
}else
{
    return $data;
}

}
?>

1个回答

获取用户信息的url参数有问题吧

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!