query($sql); $result->setFetchMode(PDO::FETCH_ASSOC); //数字索引方式 while ($row = $result->fetch()){ $data[]=$row['openId']; } $next_openid=''; $n=0; $openid=array(); a: $access_token=getAccesstoken(); $url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$access_token."&next_openid=".$next_openid; $response=http_request($url); $subData=(json_decode($response,true)); $total=$subData['total']; $count=$subData['count']; $openid=array_merge($openid,$subData['data']['openid']); $next_openid=$subData['next_openid']; $n+=$count; if ($n < $total ){ goto a; } $check=array_intersect($data,$openid); $where=""; foreach ($check as $v){ $where.="'".$v."',"; } $where=rtrim($where,","); $updateSql="UPDATE lottery_user SET subscribe=1 WHERE openId IN(".$where.")"; $updateResult=$pdo->exec($updateSql); $updateError=$pdo->errorInfo(); $writeLogArr['lottery']=$data; $writeLogArr['subscribe']=$openid; $writeLogArr['intersect']=$check; write_log("checkSubscribe.php".json_encode($writeLogArr)); ?>