Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

41 wiersze
1.2 KiB

  1. <?php
  2. require_once __DIR__.'/../Common/Config.php';
  3. require_once __DIR__.'/../Common/Function.php';
  4. $pdo = new PDO("sqlsrv:Server=".HOST.";Database=".DB, USER, PASSWORD);//5.6版本pdo连接sqlsrv
  5. $sql="SELECT DISTINCT openId FROM lottery_user";
  6. $result=$pdo->query($sql);
  7. $result->setFetchMode(PDO::FETCH_ASSOC); //数字索引方式
  8. while ($row = $result->fetch()){
  9. $data[]=$row['openId'];
  10. }
  11. $next_openid='';
  12. $n=0;
  13. $openid=array();
  14. a:
  15. $access_token=getAccesstoken();
  16. $url="https://api.weixin.qq.com/cgi-bin/user/get?access_token=".$access_token."&next_openid=".$next_openid;
  17. $response=http_request($url);
  18. $subData=(json_decode($response,true));
  19. $total=$subData['total'];
  20. $count=$subData['count'];
  21. $openid=array_merge($openid,$subData['data']['openid']);
  22. $next_openid=$subData['next_openid'];
  23. $n+=$count;
  24. if ($n < $total ){
  25. goto a;
  26. }
  27. $check=array_intersect($data,$openid);
  28. $where="";
  29. foreach ($check as $v){
  30. $where.="'".$v."',";
  31. }
  32. $where=rtrim($where,",");
  33. $updateSql="UPDATE lottery_user SET subscribe=1 WHERE openId IN(".$where.")";
  34. $updateResult=$pdo->exec($updateSql);
  35. $updateError=$pdo->errorInfo();
  36. $writeLogArr['lottery']=$data;
  37. $writeLogArr['subscribe']=$openid;
  38. $writeLogArr['intersect']=$check;
  39. write_log("checkSubscribe.php".json_encode($writeLogArr));
  40. ?>