我希望在他/她在我的混合应用程序中签名后(基于IBM Worklight 6.0)向用户发送电子邮件。
我想将用户的参数(电子邮件ID)传递给托管的PHP文件。我尝试直接在URL中发送邮件作为Follows,这有效:
http://www.xxxyyyzzz.comli.com/email.php?a=someEmailAddress@someEmailHost.com
如何通过Worklight适配器执行相同操作?
ADAPTER.XML
<wl:adapter name="sendmail"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.worklight.com/integration"
xmlns:http="http://www.worklight.com/integration/http">
<displayName>sendmail</displayName>
<description>sendmail</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>xxxyyy.comli.com</domain>
<port>80</port>
<sslCertificateAlias></sslCertificateAlias>
<sslCertificatePassword></sslCertificatePassword>
-->
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="getStories"/>
<procedure name="getStoriesFiltered"/>
</wl:adapter>
ADAPTER IMP.JS
function getStories(interest) {
path = getPath(interest);
var input = {
method : 'get',
returnedContentType : 'html',
path : '/email.php?a='
};
return WL.Server.invokeHttp(input);
}
答案 0 :(得分:1)
参数在哪里?您没有将其传递给适配器程序AFAICT。
试试下面的内容(我没有端到端地测试它,因为我没有服务器用PHP脚本听取请求)。
<强> HTML 强>
Your email address: <input type="text" id="emailaddr"/>
<input type="button" onclick="sendEmail()" value="Submit Email Address"/>
<强>的JavaScript 强>
function sendEmail() {
var invocationData = {
adapter : 'myAdapter',
procedure : 'sendEmailProcedure',
parameters : [$('#emailaddr').val()] // the email adrress taken from the HTML...
};
var options = {
onSuccess : success,
onFailure : failure
};
WL.Client.invokeProcedure(invocationData, options);
}
function success() {
WL.Logger.debug ("invocation succeeded.");
}
function failure() {
WL.Logger.debug ("invocation failed.");
}
<强> myAdapter.xml 强>
...
...
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>host-address</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
<procedure name="sendEmailProcedure"/>
<强> myAdapter-impl.js 强>
function sendEmailProcedure(emailAddress) {
var input = {
method : 'get',
returnedContentType : 'html',
path : '/email.php?a=' + emailAddress
};
return WL.Server.invokeHttp(input);
}
查看相关问题: