我正在尝试使用 AdobeDigital Publishing Suite Web Viewer.
我已经正确设置了我的 Web 查看器 - 它在我的网站中运行。但是,并不是验证每个用户都有权访问 Web 查看器正在访问的作品集。Adobe 有一些关于如何做到这一点的文档,但他们的文档似乎缺乏。似乎 Adobe 要求我获取 Adobe 的用户名和密码 - 但这是不对的。我怀疑 Adobe 会邀请网络钓鱼。但这不是我迷失的唯一一点。
我当前的脚本如下:
var wvQueryParamGroups = location.search.match(/[?&^#]wv=(s[\/%\-.\w]+)/),
wvQueryParam = wvQueryParamGroups && wvQueryParamGroups.length === 2 ? decodeURIComponent(wvQueryParamGroups[1]) : null;
function loadXMLDoc(url, successCallback, failCallback) {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlhttp.responseText, "application/xml");
successCallback(xmlDoc);
} else if (xmlhttp.readyState == 4 && xmlhttp.status == 0) {
alert("unsuccessful cross-domain data access attempt?");
failCallback(xmlhttp.status);
} else if (xmlhttp.readyState == 4) {
failCallback(xmlhttp.status);
} else {
console.log('readystate=' + xmlhttp.readyState + ', status=' + xmlhttp.status);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
function directEntitlementSignIn(directEntitlementURL, emailAddress, password, appID, authTokenSuccess, authTokenFail) {
var response;
if (!authTokenSuccess || !authTokenFail) {
throw new Error('Callbacks are required: ');
}
loadXMLDoc(directEntitlementURL + '?emailAddress=' + emailAddress + '&password=' + password + '&appId=' + appID,
handleToken = function (data) {
token = data.documentElement.childNodes[0].innerHTML;
authTokenSuccess(token);
}
);
}
function onAuthTokenSuccess(token) {
alert(token);
// pass the token into the Authenticator class's login method
}
function onAuthTokenFail(status) {
alert("fail: " + status);
// prompt the user to try logging in again
}
function signIn(emailAddress, password) {
var deAPIURL = 'http://127.0.0.1/hostDemos r27/authHard/test.php';
var emailAddress; // user's login ID.....get from form
var password; // user's password ... get from form
var appID = 'com.publisher.magazine';
directEntitlementSignIn(deAPIURL, emailAddress, password, appID, onAuthTokenSuccess, onAuthTokenFail);
}
function eventCallback(ev) {
if (ev.eventType == "paywall") {
return false;
}
if (ev.eventType == "metadata") {
return true;
}
console.log(ev);
return true;
}
function errorCallback (message) {
console.log(message);
return true;
}
function redirectCallbackHandler (message) {
console.log(message);
}
var wv_appName = "Professional Roofing";
var wv_accountID = Account_ID_Is_Here; //Hiding account ID purposely
var wv_folio = "August 2014 Issue";
var wv_article = "Cover";
var wv_url = '/s/' + wv_appName + '/' + wv_accountID + '/' + wv_folio + '/' + wv_article + '.html';
console.log(wv_url);
var bridge = adobeDPS.frameService.createFrame({
boolIsFullScreen : true,
parentDiv : 'mainContainer',
wrapperClasses : 'uniqueFrame',
iframeID : 'demoFrame',
accountIDs : wv_accountID,
wvParam : wvQueryParam ? wvQueryParam : wv_url,
curtainClasses : 'mask hidden',
eventCallback : eventCallback,
errorCallback : errorCallback,
redirectCallback : redirectCallbackHandler
});