Example #1
0
 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)) {
         $data = array('name' => $name, 'description' => $description, 'groupid' => 0);
         $state = pdo_insert('uni_account', $data);
         if (!$state) {
             message('添加公众号失败');
Example #2
0
		$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'];
			$wechat['account'] = $basicinfo['username'];