本文整理汇总了PHP中CSocServUtil::checkOAuthProxyParams方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocServUtil::checkOAuthProxyParams方法的具体用法?PHP CSocServUtil::checkOAuthProxyParams怎么用?PHP CSocServUtil::checkOAuthProxyParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocServUtil
的用法示例。
在下文中一共展示了CSocServUtil::checkOAuthProxyParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Authorize
public function Authorize()
{
global $APPLICATION;
$APPLICATION->RestartBuffer();
$authError = SOCSERV_AUTHORISATION_ERROR;
if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
$redirect_uri = self::CONTROLLER_URL . "/redirect.php?redirect_to=" . urlencode(CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code")));
} else {
$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code"));
}
$this->entityOAuth = $this->getEntityOAuth($_REQUEST['code']);
if ($this->entityOAuth->GetAccessToken($redirect_uri) !== false) {
$arFBUser = $this->entityOAuth->GetCurrentUser();
if (is_array($arFBUser) && isset($arFBUser["id"])) {
$arFields = self::prepareUser($arFBUser);
$authError = $this->AuthorizeUser($arFields);
}
}
}
$bSuccess = $authError === true;
$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
if ($bSuccess) {
CSocServUtil::checkOAuthProxyParams();
$url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "" : $GLOBALS["APPLICATION"]->GetCurDir();
if (isset($_REQUEST['backurl'])) {
$parseUrl = parse_url($_REQUEST['backurl']);
$urlPath = $parseUrl["path"];
$arUrlQuery = explode('&', $parseUrl["query"]);
foreach ($arUrlQuery as $key => $value) {
foreach ($aRemove as $param) {
if (strpos($value, $param . "=") === 0) {
unset($arUrlQuery[$key]);
break;
}
}
}
$url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
}
}
if ($authError === SOCSERV_REGISTRATION_DENY) {
$url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
$url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
} elseif ($bSuccess !== true) {
$url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
}
if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
$url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
}
?>
<script type="text/javascript">
if(window.opener)
window.opener.location = '<?php
echo CUtil::JSEscape($url);
?>
';
window.close();
</script>
<?php
die;
}
示例2: Authorize
public function Authorize()
{
$GLOBALS["APPLICATION"]->RestartBuffer();
$bSuccess = false;
if (!isset($_REQUEST["oauth_token"]) || $_REQUEST["oauth_token"] == '') {
$tw = new CTwitterInterface();
$callback = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID);
if ($tw->GetRequestToken($callback)) {
$tw->RedirectAuthUrl();
}
} elseif (CSocServAuthManager::CheckUniqueKey()) {
$tw = new CTwitterInterface(false, false, $_REQUEST["oauth_token"], $_REQUEST["oauth_verifier"]);
if (($arResult = $tw->GetAccessToken()) !== false && $arResult["user_id"] != '') {
$twUser = $tw->GetUserInfo($arResult["user_id"]);
$first_name = $last_name = "";
if (is_array($twUser) && $twUser["name"] != '') {
$aName = explode(" ", $twUser["name"]);
$first_name = $aName[0];
if (isset($aName[1])) {
$last_name = $aName[1];
}
}
$arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arResult["user_id"], 'LOGIN' => $arResult["screen_name"], 'NAME' => $first_name, 'LAST_NAME' => $last_name);
if (isset($twUser["profile_image_url"]) && self::CheckPhotoURI($twUser["profile_image_url"])) {
$twUser["profile_image_url"] = preg_replace("/_normal\\./i", ".", $twUser["profile_image_url"]);
if ($arPic = CFile::MakeFileArray($twUser["profile_image_url"])) {
$arFields["PERSONAL_PHOTO"] = $arPic;
}
}
$arFields["PERSONAL_WWW"] = "https://twitter.com/" . $arResult["screen_name"];
if (strlen(SITE_ID) > 0) {
$arFields["SITE_ID"] = SITE_ID;
}
if (COption::GetOptionString('socialservices', 'last_twit_id', '1') == 1) {
if (isset($twUser["status"]["id_str"])) {
COption::SetOptionString('socialservices', 'last_twit_id', $twUser["status"]["id_str"]);
}
}
$authError = $this->AuthorizeUser($arFields);
$bSuccess = $authError === true;
}
}
if ($bSuccess) {
CSocServUtil::checkOAuthProxyParams();
$aRemove = array("logout", "auth_service_error", "auth_service_id", "oauth_token", "oauth_verifier", "check_key", "current_fieldset", "ncc");
$url = isset($_REQUEST['backurl']) ? $_REQUEST['backurl'] : $GLOBALS['APPLICATION']->GetCurPageParam($bSuccess === true ? '' : 'auth_service_id=' . self::ID . '&auth_service_error=' . $bSuccess, $aRemove);
if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
$url = preg_match("/\\?/", $url) ? $url . "¤t_fieldset=SOCSERV" : $url . "?current_fieldset=SOCSERV";
}
echo '
<script type="text/javascript">
if(window.opener)
window.opener.location = \'' . CUtil::JSEscape($url) . '\';
window.close();
</script>
';
die;
} else {
// some error occured
}
}
示例3: Authorize
public function Authorize()
{
global $APPLICATION;
$APPLICATION->RestartBuffer();
$authError = SOCSERV_AUTHORISATION_ERROR;
if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME')) {
$redirect_uri = self::CONTROLLER_URL . "/redirect.php?redirect_to=" . urlencode(CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code")));
} else {
$redirect_uri = CSocServUtil::GetCurUrl('auth_service_id=' . self::ID, array("code"));
}
$this->entityOAuth = new CFacebookInterface(false, false, $_REQUEST["code"]);
if ($this->entityOAuth->GetAccessToken($redirect_uri) !== false) {
$arFBUser = $this->entityOAuth->GetCurrentUser();
if (is_array($arFBUser) && isset($arFBUser["id"])) {
$arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arFBUser["id"], 'LOGIN' => "FB_" . $arFBUser["id"], 'EMAIL' => $arFBUser["email"] != '' ? $arFBUser["email"] : '', 'NAME' => $arFBUser["first_name"], 'LAST_NAME' => $arFBUser["last_name"], 'OATOKEN' => $this->entityOAuth->getToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
if (isset($arFBUser['picture']['data']['url']) && !$arFBUser['picture']['data']['is_silhouette']) {
$picture_url = CFacebookInterface::GRAPH_URL . '/' . $arFBUser['id'] . '/picture?type=large';
$temp_path = CFile::GetTempName('', 'picture.jpg');
$ob = new \Bitrix\Main\Web\HttpClient(array("redirect" => true));
$ob->download($picture_url, $temp_path);
$arPic = CFile::MakeFileArray($temp_path);
if ($arPic) {
$arFields["PERSONAL_PHOTO"] = $arPic;
}
}
if (isset($arFBUser['birthday'])) {
if ($date = MakeTimeStamp($arFBUser['birthday'], "MM/DD/YYYY")) {
$arFields["PERSONAL_BIRTHDAY"] = ConvertTimeStamp($date);
}
}
if (isset($arFBUser['gender']) && $arFBUser['gender'] != '') {
if ($arFBUser['gender'] == 'male') {
$arFields["PERSONAL_GENDER"] = 'M';
} elseif ($arFBUser['gender'] == 'female') {
$arFields["PERSONAL_GENDER"] = 'F';
}
}
$arFields["PERSONAL_WWW"] = $this->getProfileUrl($arFBUser['id']);
if (strlen(SITE_ID) > 0) {
$arFields["SITE_ID"] = SITE_ID;
}
$authError = $this->AuthorizeUser($arFields);
}
}
}
$bSuccess = $authError === true;
$aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset");
if ($bSuccess) {
CSocServUtil::checkOAuthProxyParams();
$url = $GLOBALS["APPLICATION"]->GetCurDir() == "/login/" ? "" : $GLOBALS["APPLICATION"]->GetCurDir();
if (isset($_REQUEST['backurl'])) {
$parseUrl = parse_url($_REQUEST['backurl']);
$urlPath = $parseUrl["path"];
$arUrlQuery = explode('&', $parseUrl["query"]);
foreach ($arUrlQuery as $key => $value) {
foreach ($aRemove as $param) {
if (strpos($value, $param . "=") === 0) {
unset($arUrlQuery[$key]);
break;
}
}
}
$url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
}
}
if ($authError === SOCSERV_REGISTRATION_DENY) {
$url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
$url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
} elseif ($bSuccess !== true) {
$url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
}
if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
$url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
}
?>
<script type="text/javascript">
if(window.opener)
window.opener.location = '<?php
echo CUtil::JSEscape($url);
?>
';
window.close();
</script>
<?php
die;
}