本文整理匯總了PHP中XWB_plugin::updateBindUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP XWB_plugin::updateBindUser方法的具體用法?PHP XWB_plugin::updateBindUser怎麽用?PHP XWB_plugin::updateBindUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XWB_plugin
的用法示例。
在下文中一共展示了XWB_plugin::updateBindUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: authCallBack
function authCallBack()
{
if (!XWB_plugin::pCfg('is_account_binding')) {
XWB_plugin::showError('網站管理員關閉了插件功能“新浪微博綁定”。請稍後再試。');
}
//--------------------------------------------------------------------
global $_G;
$sess = XWB_plugin::getUser();
$waiting_site_bind = $sess->getInfo('waiting_site_bind');
if (empty($waiting_site_bind)) {
//XWB_plugin::deny();
$siteUrl = XWB_plugin::siteUrl(0);
XWB_plugin::redirect($siteUrl, 3);
}
$sess->setOAuthKey(array(), true);
//--------------------------------------------------------------------
$wbApi = XWB_plugin::getWB();
$db = XWB_plugin::getDB();
$last_key = $wbApi->getAccessToken(XWB_plugin::V('r:oauth_verifier'));
//print_r($last_key);
if (!isset($last_key['oauth_token']) || !isset($last_key['oauth_token_secret'])) {
$api_error_origin = isset($last_key['error']) ? $last_key['error'] : 'UNKNOWN ERROR. MAYBE SERVER CAN NOT CONNECT TO SINA API SERVER';
$api_error = isset($last_key['error_CN']) && !empty($last_key['error_CN']) && 'null' != $last_key['error_CN'] ? $last_key['error_CN'] : '';
XWB_plugin::LOG("[WEIBO CLASS]\t[ERROR]\t#{$wbApi->req_error_count}\t{$api_error}\t{$wbApi->last_req_url}\tERROR ARRAY:\r\n" . print_r($last_key, 1));
XWB_plugin::showError("服務器獲取Access Token失敗;請稍候再試。<br />錯誤原因:{$api_error}[{$api_error_origin}]");
}
$sess->setOAuthKey($last_key, true);
$wbApi->setConfig();
$uInfo = $wbApi->verifyCredentials();
$sess->setInfo('sina_uid', $uInfo['id']);
$sess->setInfo('sina_name', $uInfo['screen_name']);
//print_r($uInfo);
//--------------------------------------------------------------------
/// 此帳號是否已經在當前站點中綁定
$sinaHasBinded = false;
$stat_is_bind_type = 0;
if (defined('XWB_S_UID') && XWB_S_UID > 0) {
$bInfo = XWB_plugin::getBUById(XWB_S_UID, $uInfo['id']);
} else {
$bInfo = XWB_plugin::getBindUser($uInfo['id'], 'sina_uid');
//遠程API
}
if (!is_array($bInfo) && (defined('XWB_S_UID') && XWB_S_UID > 0)) {
$bInfo = XWB_plugin::getBindUser(XWB_S_UID, 'site_uid');
//登錄狀態下再查一次API,確保沒有綁定
}
if (!empty($bInfo) && is_array($bInfo)) {
$sinaHasBinded = true;
dsetcookie($this->_getBindCookiesName($bInfo['uid']), (string) $bInfo['sina_uid'], 604800);
//核查存儲的access token是否有更新,有更新則進行自動更新
if ($bInfo['sina_uid'] == $uInfo['id'] && ($bInfo['token'] != $last_key['oauth_token'] || $bInfo['tsecret'] != $last_key['oauth_token_secret'])) {
XWB_plugin::updateBindUser($bInfo['uid'], $bInfo['sina_uid'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
//遠程API
}
}
//--------------------------------------------------------------------
/// 決定在首頁中顯示什麽浮層
$tipsType = '';
//xwb_tips_type
//已在論壇登錄
if (defined('XWB_S_UID') && XWB_S_UID) {
if ($sinaHasBinded) {
//$sinaHasBinded為true時,$bInfo必定存在
if (XWB_S_UID != $bInfo['uid'] || $bInfo['sina_uid'] != $uInfo['id']) {
$tipsType = 'hasBinded';
$sess->clearToken();
} else {
$tipsType = 'autoLogin';
}
} else {
//遠程API
$rst = XWB_plugin::addBindUser(XWB_S_UID, $uInfo['id'], (string) $last_key['oauth_token'], (string) $last_key['oauth_token_secret'], $uInfo['screen_name']);
if (!$rst) {
echo "DB ERROR";
exit;
return false;
}
$tipsType = 'bind';
dsetcookie($this->_getBindCookiesName(XWB_S_UID), (string) $uInfo['id'], 604800);
//正向綁定統計上報
$sess->appendStat('bind', array('uid' => $uInfo['id'], 'type' => 1));
}
} else {
//從 wb 登錄後 檢查用戶是否綁定,如果綁定了 則在附屬站點自
if ($sinaHasBinded) {
require_once XWB_P_ROOT . '/lib/xwbSite.inc.php';
$result = xwb_setSiteUserLogin((int) $bInfo['uid']);
if (false == $result) {
dsetcookie($this->_getBindCookiesName($bInfo['uid']), -1, 604800);
XWB_plugin::delBindUser($bInfo['uid']);
//遠程API
$tipsType = 'siteuserNotExist';
} else {
$stat_is_bind_type = 1;
$tipsType = 'autoLogin';
}
} else {
//已登錄WB,沒有附屬站點的帳號 引導注冊
$sess->setInfo('waiting_site_reg', '1');
$tipsType = 'reg';
//.........這裏部分代碼省略.........