getUserList() 공개 메소드

批量获取关注用户列表
public getUserList ( unknown $next_openid = '' )
$next_openid unknown
예제 #1
0
 function getNewUser()
 {
     ini_set('max_execution_time', '0');
     ini_set('memory_limit', '512M');
     import('ORG.wechat');
     $options = array('appid' => 'wx35a55b1c419603dc', 'appsecret' => 'ce22a59f9459611c9c38d17721659b95');
     $weObj = new Wechat($options);
     $userList = $weObj->getUserList();
     $page = (int) ceil($userList['total'] / 10000);
     //得出有多少页
     $userDB = M('user');
     $yidong2DB = M('yidong3');
     p("start");
     foreach ($userList['data']['openid'] as $openid) {
         $user = $userDB->where(array('open_id' => $openid))->find();
         if ($user == null || $user['id'] > 92214) {
             $yidong2['open_id'] = $openid;
             //p($openid.'<br/>');
             $yidong2DB->data($yidong2)->add();
         }
     }
     for ($i = 1; $i < $page; $i++) {
         $userList = $weObj->getUserList($userList['next_openid']);
         foreach ($userList['data']['openid'] as $openid) {
             $user = $userDB->where(array('open_id' => $openid))->find();
             if ($user == null || $user['id'] > 92214) {
                 $yidong2['open_id'] = $openid;
                 p($openid . '<br/>');
                 $yidong2DB->data($yidong2)->add();
             }
         }
         p("*******{$i}*******");
     }
     p("*******end*******");
     exit;
 }
예제 #2
0
<?php

include "../qy-sdk/wechat.class.php";
function _log($text)
{
    //$result = file_put_contents('wechat.log.'.date('Y-m-d'), $text."\n", FILE_APPEND);
    //if (!$result) {
    openlog("wechat", LOG_PID | LOG_PERROR, LOG_LOCAL0);
    syslog(LOG_DEBUG, $text);
    closelog();
    //}
}
$options = ['token' => 'nizhidaoma', 'encodingaeskey' => 'xc8rRK4iOQjTJK9hOYhRrC9sPBJvF5Jhjq203iMC7vF', 'appid' => 'wxe85832e232e73f41', 'appsecret' => '4c8f1aa381675dd2569fc9482052afdc', 'debug' => true, 'logcallback' => '_log'];
$weObj = new Wechat($options);
$result = $weObj->getUserList();
//$openids = $result['data']['openid'];
$openids = ['okOSbjsFzcUg3UKR8m1rcsDm1LFo', 'okOSbjs8bPyUXm8UiwSe7ohdijCY', 'ogs-bjqeIM4nvT1NKqwM6kO6tonQ', 'ogs-bjlTUqTXyX4JH8TpDrXKZnYs', 'okOSbjrOZwM2wWwxZCHc7OERoYgU', 'okOSbjp_6-rPV5_NL34l8o3IcWTM', 'okOSbjihH2adDfL6Lweb8EPByZZ8', 'okOSbjhkrfGqd-yAQ20ZXHmKyzXw', 'okOSbjuKB0avooLLW7QyyZg2lnKg', 'okOSbjgl8dxxfTQ4CHVXJilFDUXA', 'okOSbjlYWDGvWCh7tNz7IJyIStfY', 'ogs-bjlfxXPVq0eh8pJCdtmUCMz8'];
foreach ($openids as $openid) {
    $info = $weObj->getUserInfo($openid);
    echo var_export($info, true);
    echo '\\n';
}
//echo var_export($result, true);
//echo '\n';
if ($result == false) {
    echo $weObj->errCode;
    echo '\\n';
    echo $weObj->errMsg;
    echo '\\n';
}
die;