} } if (checksubmit('submit')) { load()->func('file'); if (intval($_GPC['type']) == '2') { $type = 'yixin'; } elseif (intval($_GPC['type']) == '3') { $type = 'alipay'; } else { $type = 'wechat'; } $username = trim($_GPC['wxusername']); $password = md5(trim($_GPC['wxpassword'])); if (!empty($username) && !empty($password)) { if ($type == 'wechat') { $loginstatus = account_weixin_login($username, $password, trim($_GPC['verify'])); if (is_error($loginstatus)) { message($loginstatus['message'], url('account/post-step', array('uniacid' => $uniacid, 'step' => 2)), 'error'); } $basicinfo = account_weixin_basic($username); } elseif ($_GPC['type'] == 'yixin') { $loginstatus = account_yixin_login($username, $password, trim($_GPC['verify'])); if (is_error($loginstatus)) { message($loginstatus['message'], url('account/post-step', array('uniacid' => $uniacid, 'step' => 2)), 'error'); } $basicinfo = account_yixin_basic($username); } if (empty($basicinfo['name'])) { message('一键获取信息失败,请手动设置公众号信息!', url('account/post-step/', array('uniacid' => $uniacid, 'step' => 3)), 'error'); } if (empty($uniacid)) {
load()->func('file'); if (checksubmit('submit')) { if ($_GPC['type'] == 2) { $tablename = 'account_yixin'; $type = 'yixin'; } else { $tablename = 'account_wechats'; $type = 'wechat'; } $account = array(); if (!empty($_GPC['model']) && $_GPC['model'] == 2) { $username = $_GPC['wxusername']; $password = md5($_GPC['wxpassword']); if (!empty($username) && !empty($password)) { if ($type == 'wechat') { $loginstatus = account_weixin_login($username, $password, ''); $basicinfo = account_weixin_basic($username); } elseif ($_GPC['type'] == 'yixin') { $loginstatus = account_yixin_login($username, $password, ''); $basicinfo = account_yixin_basic($username); } if (empty($basicinfo['name'])) { message('一键获取信息失败,请手动添加该公众帐号并反馈此信息给管理员!'); } $account['username'] = $_GPC['wxusername']; $account['password'] = md5($_GPC['wxpassword']); $account['lastupdate'] = TIMESTAMP; $account['name'] = $basicinfo['name']; $account['account'] = $basicinfo['account']; $account['original'] = $basicinfo['original']; $account['signature'] = $basicinfo['signature'];
function account_weixin_remark($fakeid, $remark, $groupid = 0) { //备注 if (account_weixin_login()) { global $_W; $username = $_W['account']['username']; if (empty($_W['cache']['wxauth'][$username])) { cache_load('wxauth:' . $username . ':'); } $auth = $_W['cache']['wxauth'][$username]; $url = WEIXIN_ROOT . '/cgi-bin/modifycontacts'; $post = array('remark' => $remark, 'tofakeuin' => $fakeid, 'token' => $auth['token'], 'lang' => 'zh_CN', 'action' => 'setremark', 't' => 'ajax-response'); $response = ihttp_request($url, $post, array('CURLOPT_COOKIE' => $auth['cookie'], 'CURLOPT_REFERER' => WEIXIN_ROOT . '/cgi-bin/contactmanage?t=user/index&pagesize=10&pageidx=0&type=0&groupid=' . $groupid . '&token=' . $auth['token'] . '&lang=zh_CN')); $result = json_decode($response['content'], 1); return $result; } return false; }
$data['hash'] = random(5); $data['token'] = random(32); if (pdo_insert('wechats', $data)) { $id = pdo_insertid(); } } cache_build_account(); message('更新公众号成功!', create_url('account/post', array('id' => $id))); } else { $wechat = array(); if (!empty($id)) { $wechat = pdo_fetch("SELECT * FROM ".tablename('wechats')." WHERE weid = '$id'"); } if(!empty($wechat['username']) && (empty($wechat['lastupdate']) || TIMESTAMP - $wechat['lastupdate'] > 86400 * 7)) { $loginstatus = account_weixin_login($wechat['username'], $wechat['password']); $basicinfo = account_weixin_basic(); if (!empty($basicinfo['name'])) { $update = array( 'name' => $basicinfo['name'], 'account' => $basicinfo['username'], 'original' => $basicinfo['original'], 'signature' => $basicinfo['signature'], 'country' => $basicinfo['country'], 'province' => $basicinfo['province'], 'city' => $basicinfo['city'], 'lastupdate' => TIMESTAMP, ); pdo_update('wechats', $update, array('weid' => $id)); cache_build_account(); $wechat['name'] = $basicinfo['name'];