function getAppSecurityToken($siteid = null, $ip = null) { $body = WindowsLiveLogin::fetch(WindowsLiveLogin::getAppLoginUrl($siteid, $ip)); if (!$body) { WindowsLiveLogin::debug("Error: getAppSecurityToken: Could not fetch the application security token."); return; } preg_match('/\\{"token":"(.*)"\\}/', $body, $matches); if (count($matches) == 2) { return $matches[1]; } else { WindowsLiveLogin::debug("Error: getAppSecurityToken: Failed to extract token: {$body}"); return; } }