When getting the list of followers through access_token, it shows that this operation cannot be performed.

what happens when you get a list of followers through access_token after getting access_token and show that this operation cannot be performed?

$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);
  curl_close($ch);
  $jsoninfo = json_decode($output, true);
  $access_token = $jsoninfo["access_token"];
  //echo $access_token;
  
  //openid

 
  //
  function userlist($access_token){
       $url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=.$access_token.&next_openid=NEXT_OPENID 

";
       $content = $this->request($url);

       $content = json_decode($content);
       $openidList = $content -> data->openid;
       var_dump($openidList);

       echo ":".$content->total.".<br/>";
       echo "openid:<br/>";
       foreach($openidList as $key => $value){
           echo $value."<br/>";
       }
   }
Feb.26,2021

errors are posted to have a look


your official account may not be certified, so you don't have permission!

the following is modified on March 30, 2018:

No. 1: you posted the source code, not the error code!
2: your source code is also incomplete, there is no way for others to debug! For example:
$content = $this- > request ($url);
what object is $this? What is the definition of the request method?
No. 3: there is also an obvious error in your source code. In PHP, variables in single quotes are treated as strings, so

$url='https://api.weixin.qq.com/cgi-bin/user/get?access_token=.$access_token.&next_openid=NEXT_OPENID
';

this sentence, the URL you requested is really:

$url='https://api.weixin.qq.com/cgi-bin/user/get?access_token=.$access_token.&next_openid=NEXT_OPENID

this is wrong and double quotation marks should be used. Also, your parameter NEXT_OPENID should be a variable, and you are just a string of uppercase letters!
to sum up, it is normal that your code cannot get user information, it has nothing to do with the permissions of the official account, it is a code-level problem!
finally, an executable code is attached for your reference:

<?php
$appid='';//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);
curl_close($ch);
$jsoninfo = json_decode($output, true);
$access_token = $jsoninfo["access_token"];
echo $access_token;

//openid
userlist($access_token);

//
function userlist($access_token){

   $url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=$access_token";
echo 'url'.$url;

   // $content = $this->request($url);
   $content=curl1($url);
   print_r($content);
   $content = json_dcode($content);
   $openidList = $content -> data->openid;
   var_dump($openidList);

   echo ':'.$content->total.'.<br/>';
   echo 'openid:<br/>';
   foreach($openidList as $key => $value){
       echo $value.'<br/>';
   }
}

function curl1($url1){

$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $url1);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, FALSE); 
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch1);
curl_close($ch1);
return $output;
}
Menu