Tuesday, October 16, 2012

Integration of Oracle Social Network and APEX

At Oracle Open World (OOW) Martin and I had a lot of fun integrating the Oracle Social Network (OSN) with Oracle Application Express (APEX).

In short there was a developer challenge at OOW where teams had to find a good use case to integrate OSN with the technology of your choice... Martin and I obviously used APEX... and we won! We hacked it together in one night! Jake (one of the organisers) wrote a nice blog post about it or you can read about it on the Oracle Blog. In that post there's a video of Martin and I smiling because the jury just told us we won :-)

Here's a video where you can see what we build:



I didn't really want to talk about the developer challenge in this post, but more on how you can integrate the Oracle Social Network with APEX. So lets concentrate on that now...

The Oracle Social Network is still in beta and we got only access to it during OOW (and a couple of days after to make the video). During the challenge we used the PL/SQL API which was part of the documentation (edit: I'm unsure what we got will be part of the production release, as it was Noel Portugal who build that example for the challenge. Thanks Noel!). As we have some great web service API's in APEX I immediately thought to try to use those. Unfortunately during the challenge we didn't have enough time to get things working, but straight after I discussed with Jason Straub and after he told me I didn't need to specifically set the complete headers, it was working great (Thanks Jason!).

Below I try to explain the most important parts of the code.


To integrate with OSN you can use RESTfull webservices. The OSN documentation is a great resource and the calls are well documented.
Line 119 shows the url you need to do to post a new message. You post a message to a conversation. In the full package you can see how to create a conversation too.
Line 120 shows what you have to post, basically a json string with the message.
Line 121 shows the REST request; you call a url, and do a post with in the body the json string. As everything is going over https you have to have your Oracle wallet configured with the certificate.

If you look at the complete osn_pkg package, the submit_osn procedure is the call we do in the video. As OSN is secured you first have to connect with a username and password. You get back a cookie and random id and you have to set that in the header of all the next calls.
By using the apex_web_service package you only need to set the headers once. Next in the procedure we create a new conversation, we add more members to it so others can participate in the conversation. In the conversation we add a message and a document (screenshot) if there's one.

I made the package open source on GitHub, so you can see the complete package there and you can quickly integrate with OSN from APEX. The only thing I want to ask is, if you improve it or integrate other parts of the Oracle Social Network once it launches, give your code back as well so we can use this project as a great source for the OSN and APEX community.

Hope you like it...

7 comments:

fateh.cis said...

Thanks Dimitri,
Actually, Me and some other people are looking to enabling live chat between APEX application end users.

There are a few threads on OTN, but it is not clear..

Best Regards,
Fateh

Kris said...

Congratulations Dimitri!

Anonymous said...

Have you ever thought about creating an e-book or guest authoring on other
blogs? I have a blog centered on the same ideas you discuss and would really like to have you share some stories/information.
I know my readers would enjoy your work. If you're even remotely interested, feel free to send me an e mail.

Also visit my web page le meilleur blog de referencement google

Dmitri Tchikine said...

I am curious about "The OSN documentation is a great resource and the calls are well documented". Maybe they were documented for this OOW challenge? No amnount of searching Oracle documentation helps to find that RESTful API. Is there any reference you could share? Thanks

Dimitri Gielis said...

Yes, I only saw the documentation at the time of OOW. I'm unsure how the doc looks like today.

Omar Sawalhah said...

Well Done,
But more details on adding screenshots is needed, kindly

Omar

Omar Sawalhah said...

Hi Dmitri,
How the screenshot trick is done, any clue would be great.

Omar