I have included the Pubnub-4.0.0.jar file into my webroot. (Pubnub-4.0.0.jar can be downloaded here: https://www.pubnub.com/docs/java/pubnub-java-sdk-v4)
I am trying to get the “HERE NOW” java code into my coldfusion project and am having some trouble in doing so.
The java code is as follows:
PNConfiguration pnConfiguration = new PNConfiguration(); pnConfiguration.setSubscribeKey("SubscribeKey") PubNub pubnub = new PubNub(pnConfiguration); pubNub.hereNow() .channels(Arrays.asList("ch1", "ch2", "ch3")) // who is present on those channels? .includeState(true) // include state with request (false by default) .includeUUIDs(true) // if false, only shows occupancy count .async(new PNCallback<PNHereNowResult>() { @Override public void onResponse(PNHereNowResult result, PNStatus status) { } });
My corresponding Coldfusion code is as follows:
<cfobject type="java" class="com.pubnub.api.PNConfiguration" name="objPNConfiguration" > <cfset PNConfiguration = objPNConfiguration.init() > <cfset PNConfiguration.setSubscribeKey("SubscribeKey") > <cfobject type="java" class="com.pubnub.api.PubNub" name="objPubNub" > <cfset pubnub = objPubNub.init(PNConfiguration) > <cfset tmp = pubnub.hereNow({channels: "5A4B3B59-FA6A-F22A-404F18EFA8112508"}) > <cfdump var="#tmp#" >
I do not get any errors returned. I feel the way in which I am calling the “hereNow” method is incorrect or the way in which I am trying to display the results is incorrect.
Can anyone provide any assistance with regards to this? Thanks
Answer
Pubnub provided a REST API call for this. https://s3.amazonaws.com/pubnub/sdk/RESTful+Documentation/index.html#presence-here-now-get Thankyou Pubnub.