Exemplo n.º 1
0
function handleTokenResponse($token, $error = null)
{
    $authCookie = $_COOKIE[AUTHCOOKIE];
    $cookieValues = parseQueryString($authCookie);
    if (!empty($token)) {
        $cookieValues[ACCESSTOKEN] = $token->{ACCESSTOKEN};
        $cookieValues[SCOPE] = $token->{SCOPE};
        $cookieValues[EXPIRESIN] = $token->{EXPIRESIN};
        if (!empty($token->{REFRESHTOKEN})) {
            saveRefreshToken($token->{REFRESHTOKEN});
        }
    }
    if (!empty($error)) {
        $cookieValues[ERRORCODE] = $error[ERRORCODE];
        $cookieValues[ERRORDESC] = $error[ERRORDESC];
    }
    setrawcookie(AUTHCOOKIE, buildQueryString($cookieValues), 0, '/', $_SERVER[SERVER_NAME]);
}
Exemplo n.º 2
0
function handleTokenResponse($token, $error = null)
{
    $resp = array();
    if (!empty($token)) {
        $resp[ACCESSTOKEN] = $token->{ACCESSTOKEN};
        $resp[SCOPE] = $token->{SCOPE};
        $resp[EXPIRESIN] = $token->{EXPIRESIN};
        if (!empty($token->{REFRESHTOKEN})) {
            saveRefreshToken($token->{REFRESHTOKEN});
        }
    }
    if (!empty($error)) {
        $resp[ERRORCODE] = $error[ERRORCODE];
        $resp[ERRORDESC] = $error[ERRORDESC];
    }
    $responseUrl = ENDURL . '?' . buildQueryString($resp);
    header('Location: ' . $responseUrl);
}