$liveid_appid,"secret"=>$liveid_secret,"securityalgorithm"=>$liveid_secalgo,"returnurl"=>$liveid_return,"policyurl"=>$liveid_policy); if($liveid_appid && $liveid_secret && $liveid_secalgo) { // Initialize the WindowsLiveLogin module. $wll = WindowsLiveLogin::initFromXml(false,$liveid_settings); $wll->setDebug($DEBUG); $APPID = $wll->getAppId(); $login_html = "
This application does not know who you are! Click the Sign in link above.
"; $consent_html = null; // If the user token obtained from sign-in through Web Authentication // has been cached in a site cookie, attempt to process it and extract // the user ID. $token = @$_COOKIE[$WEBAUTHCOOKIE]; $userid = null; if ($token) { $user = $wll->processToken($token); if ($user) { $userid = $user->getId(); } } // If the user ID is obtained successfully, prepare the message // to include the consent URL if a valid token is not present in the // persistent store; otherwise display the contents of the token. if ($userid) { $login_html = "Now this application knows that you are the user with ID = \"$userid\".
"; $consenturl = $wll->getConsentUrl($OFFERS); $consent_html = "Please click here to grant consent so that we may access your Windows Live data.
"; // Attempt to get the raw consent token from persistent store for the // current user ID. //$tokens = new TokenDB($TOKENDB); //$token = $tokens->getToken($userid); $token = get_option($userid); $consenttoken = $wll->processConsentToken($token); if ($consenttoken) { if (!$consenttoken->isValid()) { wp_redirect($consenturl); } } // If a consent token is found and is stale, try to refresh it and store // it in persistent storage. if ($consenttoken) { if (!$consenttoken->isValid()) { if ($consenttoken->refresh() && $consenttoken->isValid()) { //$tokens->setToken($userid, $consenttoken->getToken()); update_option($userid,$consenttoken->getToken()); } } if ($consenttoken->isValid()) { // Convert Unix epoch time stamp to user-friendly format. $expiry = $consenttoken->getExpiry(); $expiry = date(DATE_RFC2822, $expiry); //Prepare the message to display the consent token contents. $consent_html = <<| Delegation token | {$consenttoken->getDelegationToken()} |
| Location ID | {$consenttoken->getLocationID()} |
| Refresh token | {$consenttoken->getRefreshToken()} |
| Expiry | {$expiry} |
| Offers | {$consenttoken->getOffersString()} |
| Context | {$consenttoken->getContext()} |
| Token | {$consenttoken->getToken()} |