if ($_POST['action'] == 'bind') { $fields = $_POST['f']; $fields['pid'] = $pid; $fields['uid'] = Passport::GetLoginUid(); $fields['nick'] = $fields['token']; $fields['valid'] = 1; if ($fields['token'] && $fields['token_secret']) { $api = Factory::CreateAPI2($fields['type'], $pid, $fields); $ret = $api->Login($_POST['verify_code']); if ($ret === true) { $fields['url'] = $api->getUrl(); $user = new User(); $users = $user->getsAll(); foreach ($users as $uid => $item) { $fields['uid'] = $uid; $thirdAccount->replace($fields); } } else { $TEMPLATE['error'] = array('type' => $fields['type'], 'msg' => $ret); $TEMPLATE['data'] = $fields; } } else { $TEMPLATE['error'] = array('type' => $fields['type'], 'msg' => '用户名和密码不能为空。'); $TEMPLATE['data'] = $fields; } } $TEMPLATE['title'] = '账号绑定'; $TEMPLATE['login_name'] = Passport::GetLoginName(); $TEMPLATE['nav']['bind'] = 'current'; if ($pid > 0) { $TEMPLATE['pid'] = $pid;
break; case 'renren': case 'sina': $code_key = 'code'; break; default: $code_key = 'oauth_verifier'; break; } $token = $api->getAccessToken($_GET[$code_key], $_GET['oauth_token']); if ($token['oauth_token']) { $api->openid = $token['openid']; $thirdAccount = new ThirdAccount(); $tableInfo = array('uid' => Passport::GetLoginUid(), 'pid' => $pid, 'type' => $api->type, 'token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret'], 'openid' => $token['openid'], 'nick' => $api->getNick(), 'url' => $api->getUrl(), 'valid' => 1); Log::customLog('token_expires_error.txt', "绑定 Token,信息:" . print_r($tableInfo, true)); $user = new User(); $users = $user->getsAll(); foreach ($users as $uid => $item) { $tableInfo['uid'] = $uid; $thirdAccount->replace($tableInfo); } redirect($_GET['redir']); echo <<<HTML <script> opener.location=opener.location; window.close(); </script> HTML; } else { echo '获取 AccessToken 失败!请稍后再试。' . $token["error_msg"] . '<span style="color:#ccc">' . print_r($token, true) . '</span>'; }