2015-09-08 56 views
0

我正在向所有设备发送推送通知,并且为此我创建了基于标记的推送通知的适配器,如下所示。从PHP脚本调用适配器

function sendTagNotification(applicationId, notificationText, notificationTags) { 
    var notificationOptions = {}; 
    notificationOptions.message = {}; 
    notificationOptions.target = {}; 

    var tags = notificationTags.split(","); 

    notificationOptions.message.alert = notificationText; 
    notificationOptions.target.tagNames = tags; 

    WL.Server.sendMessage(applicationId, notificationOptions); 

    return { 
     result : "Notification sent to users subscribed to the tag(s): '" + notificationTags + "'." 
    }; 
} 

现在我们想的办法是,我们将具有PHP脚本,将信息内容发送到工作灯适配器和sendTagNotification适配器将收到的邮件内容,并将其发送给所有移动用户。

那么有什么办法从PHP脚本调用适配器?

回答

0

假设您使用的是MobileFirst 7.0及更高版本,并且您的适配器过程受到安全测试的保护,您需要实施所谓的“机密客户端”,以充当处理OAuth challenege的OAuth客户端:http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/dev/c_non_mobile_to_mobile_services.html

可以做的另一种方法是让PHP脚本调用适配器过程URL,但该适配器过程必须使用securityTest =“wl_unprotected”不受保护。对于使用curl例如,在URL体的参数:curl http://my-host:my-port/project-context-root/adapters/adapter-name/procedure-name

如果使用MobileFirst 6.3,你可以调用从演播室适配器程序(在适配器文件夹右键单击并选择Run As>调用MobileFirst适配器程序)并输入一些细节。浏览器窗口将打开。

你应该能够复制将在那里和你的脚本调整附加的参数,网址...

+0

我们的客户端使用'v 6.3',所以我想我必须选择第二个选项,我了解url部分访问适配器,但我怎么可以传递参数 – Hunt

+0

我得到'java.lang.RuntimeException:java.io.FileNotFoundException:找不到文件:/ adapters/WLPush/sendTagNotification' 我的终点是' http://192.168.100.32:10080/RR_MobileApp/adapters/WLPush/sendTagNotification' – Hunt

+0

其实如果你使用6.3那个URL结构将不起作用。它假定REST也是7.0和更高版本的一部分......嗯。我会尽快回复你... –