Raymond Camden's Blog Rss

My experience with Adobe Wave

13

Posted in ColdFusion | Posted on 07-28-2009 | 3,427 views

I meant to get this out before vacation, but alas, time went by a bit quicker than I expected. This should not be considered a "How To" when it comes to Adobe Wave and ColdFusion. Considering that Wave is still in beta, most likely the API/process will change significantly over time (assuming Wave leaves beta). Also note that I - probably like most people - did not adequately read the docs, so some of what follows may not be exactly kosher with the docs. Please keep that in mind when reading. With that in mind, here are some quick tips and code examples.

First and foremost, for complete information on Wave, see the page at Labs: http://labs.adobe.com/technologies/wave/. This provides links to the forums, docs, etc.

Next, if you want to actually use Wave as a publisher (sign up is here), note that Adobe's verification system requires that you have an email address with the same domain as the server that will be pushing out Wave notifications. This was a problem for me as I never created an email server for ColdFusion Bloggers. Personally I (and others!) think this is a somewhat onerous requirement. Luckily I was able to complain to the right people and skip that, but most folks will not be able to do that. If you have not yet set up an email domain, then head over to Google and get their free email server service.

Once you've verified your account, you can then begin working with a feed. Be clear on this: It is not an RSS feed. I'd be a lot happier with Wave if it would work with RSS feeds, but it does not. In this case, the word feed is used in the more generic sense. Feed types can be broadcast or point to point (think messages to individual users). Most folks will probably pick broadcast and it's what I used for ColdFusion Bloggers.

Topics kind of confused me. I had thought I should maybe pick a few topics to cover the type of items ColdFusion Bloggers may send out. But I then realized that I could only broadcast with one topic at a time. If you plan on having a simple notification system like ColdFusion Bloggers, then just make one simple topic.

The next step is the code - and here is where I stumbled quite a bit. Before you can send a notification, you must first get an API token. I had thought that the API token was a simple publisher thing. I looked in the publisher site for a way to generate it but didn't have any luck. Turns out I had misunderstood the process. From what I've learned on the forums, the basic idea is:

a) on first hit, first request an API key b) make your call, and if it fails, get a new API key and try again

Basically, the API key will work for a while, but not forever. ColdFusion Bloggers is not doing this yet. From what I know, API keys are going to last quite some time, but I've got to update my code to properly handle this.

Here is the CFC I whipped up (and please ensure you understand the directives above and note that my code doesn't handle it yet) for ColdFusion Bloggers:

view plain print about
1<cfcomponent output="false">
2
3    <cffunction name="init" access="public" output="false">
4        <cfargument name="apikey" type="string" required="true">
5        <cfargument name="topic" type="string" required="false" hint="If passed, will be used as default.">
6
7        <cfset variables.apikey = arguments.apikey>
8
9        <cfif structKeyExists(arguments, "topic")>
10            <cfset variables.topic = arguments.topic>
11        </cfif>
12        <cfreturn this>
13    </cffunction>
14    
15    <cffunction name="broadcast" access="public" output="false" returnType="void">
16        <cfargument name="message" type="string" required="true">
17        <cfargument name="topic" type="string" required="false">
18        <cfargument name="link" type="string" required="false">
19        
20        <!--- ignoring the result for now --->
21        <cfset var result = "">
22        
23        <cfhttp method="post" url="https://p000-wave.adobe.com/notificationgateway/1.0/notification" result="result">
24            <cfhttpparam type="formfield" name="X-apitoken" value="#variables.apikey#">
25            <cfif not structKeyExists(arguments, "topic")>
26                <cfif structKeyExists(variables, "topic")>
27                    <cfhttpparam type="formfield" name="topic" value="#variables.topic#">
28                <cfelse>
29                    <cfthrow message="If a topic argument is not passed, one must be set in the constructor.">
30                </cfif>
31            <cfelse>
32                <cfhttpparam type="formfield" name="topic" value="#arguments.topic#">
33            </cfif>
34            <cfhttpparam type="formfield" name="message" value="#arguments.message#">
35            <cfif structKeyExists(arguments, "link")>
36                <cfhttpparam type="formfield" name="link" value="#arguments.link#">
37            </cfif>
38        </cfhttp>
39
40    </cffunction>
41
42</cfcomponent>

The code is rather simple - one simple CFHTTP hit. I pass in a message and a link. The topic is set once when I initialize the code on Application startup. Calling it then becomes as easy as:

view plain print about
1<cfset application.wave.broadcast(message="Yo!", link="http://www.foo.com")>

I tied this into both the ping code and the general blog scanner for the site and it failed quite nicely. I spent a good day thinking about it in my free time and checking logs, but nothing seemed to explain why Wave kept rejecting my calls.

Turned out it was the link. I had accidentally passed something like this for a URL: "- http://www.foo.com". Notice the - in front? That invalidates it as a URL. The error returned by Wave was just a generic 400 unless I missed something in my logging. Yep - these are the kind of errors that make you pull your hair out.

Oh - and in case you are wondering - your feed will not show in the "All Feeds" section. That's kind of sucky. The only way for someone to add ColdFusion Bloggers is to click on the install badge. For some reason, I'd expect All Feed to be, well, all feeds. I can seen not listing them all at once, but at least give me a way to see all feeds. Right now I have no idea what else is out there besides what is currently listing. Adobe really needs to address that soon I think.

Anyway, it's working for me now. When I update the code to 'properly' get the API token dynamically, I'll post that. Anyone else going to integrate Wave into their application? It seems like an interesting idea. Not sure if it will fly - but it's interesting.

I will say one thing though - AIR kicks butt. I love the fact that I can put an install badge on my site and that badge will recognize that I've already got Wave running and just add the subscription. Awesome. I'm (mostly) sure that's something any AIR application can do.

Comments

[Add Comment] [Subscribe to Comments]

Hi Ray. Thanks for the info and your insight. I'm experimenting with using Wave for website alert notifications and developer communications to internal users - so this post will help a lot :-)

I just hope Wave catches on - it seems ideal for push communications in the way that RSS isn't. Awful English there!

--
Mike
Hi Ray,

Thanks for writting up your experiences. As you know, being an early adoptor of beta software can be painful ;) Thanks for sticking it out and highlighting issues we need to work on. I agree that we need a way to list all feeds, and it's something we're working on.

And yes, what Waves does with the badge can be done by any AIR app. AIR is pretty awesome like that!

Best,
John
Hey Ray,

You inspired me to get my adobe wave feet wet. I whipped up another CFC to handle this that people should be able to take and implement on their own fairly easily. It's only for broadcast notifications right now, but it handles the API key logic.

http://textsnip.com/6d8a2f

Couldn't find a better way to share this code so that's what i got!
@John: Thanks for the help getting me up and running!

@trumans1: When I get back from vacation I'll see if I can replace my code with this. Have you considered putting this on RIAForge?
At first, I thought you were talking about Google Wave and then figured out what was going on. When the assumption was Google Wave, I thought you were falling off your rocker, considering how rough their alpha is at the moment.
Mr trumans1, it seems that something is missing (like the AdobeWave structure)... can you please post the cfm calling the cfc?
@ray: I've never posted to RIAForge before, but yea i'll definitely look into that and post alink when it's up!

@wim: I should have clarified that. The component name will be AdobeWave, so when the cfc inits it will return itself. Also here is a simple example of instantiating and using the cfc:
http://textsnip.com/d58be4
Cool, thanks! I'm a bit worried though about the e-mail/url
relationship in Adobe Wave. Does this mean that when
you have several domain names, you need an Adobe
account for each of them?
Hi again.
How did everyone find the cfhttp calls to https addresses? I may be missing something, but so far I can only seem to get "I/O Exception: peer not authenticated" errors when trying to call the API.

I can do a straight HTML Form submission (literally by creating a form and clicking submit) but the back-end automatic notification stuff seems to be beyond me! (And I've been doing this a looooong time) Perhaps it's just something I've simply not done before and everyone else does it out of habit??

Argh!
--
Mike
I should have added... I tried to export certs from my internet browser and then import them using keytool. Despite LOTS of successful imports and restarts, it's had no effect whatsoever.

Grrrrrr
I have posted my files on sourceforge, here is the download link:

https://sourceforge.net/projects/adobewavecf/files...

@michael: Are you using the method of POST in your cfhttp with the cfhttpparams set to formfield?
Trumans1: Yes, I am. I wrote my own code and then checked it against your textsnip examples. I've checked it all twice and I can't see any reason for the code to be wrong. I'm pretty sure it's something to do with certificates, but no-one else is having the problem...
I have had a breakthrough!

I have installed the intermediate certificates for GlobalSign which apparently was not a trusted authority in the version of the JRM I'm using.



Finally got a valid HTTP response! Yay!

[Add Comment] [Subscribe to Comments]