Social Connections VI Prague - An introduction to ibm connections as an appdev platform

22
There’s an API for that! Why and how to build on the IBM Connec=ons PLATFORM Mikkel Flindt Heisterberg OnTime® by IntraVision

description

"There’s an API for that! Why and how to build on the IBM Connections PLATFORM " presentation from Social Connections VI in Prague on 16-17 June 2014.

Transcript of Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Page 1: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

There’s  an  API  for  that!  Why  and  how  to  build  on  the  IBM  Connec=ons  PLATFORM  

 Mikkel  Flindt  Heisterberg  OnTime®  by  IntraVision  

Page 2: Social Connections VI Prague - An introduction to ibm connections as an appdev platform
Page 3: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Agenda  

•  Brief  intro  to  IBM  Connec=ons  as  a  PLATFORM  •  Briefer  intro  to  widgets  for  IBM  Connec=ons  •  Boxer  brief  intro  to  developing  for  the  Ac=vity  Stream  

•  Ultra  brief  intro  to  event  handlers  •  Running  short  on  =me  and  taking  ques=ons  in  the  hall  

Mikkel  Flindt  Heisterberg    TwiNer:  @lekkim  E-­‐mail:  [email protected]  hNp://lekkimworld.com  hNp://slideshare.net/lekkim  

Page 4: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

There’s  more  beneath  the  surface  

Page 5: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

The  IBM  Connec=ons  plaVorm  

Page 6: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Widgets  

Page 7: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Widgets  –  descriptor  <iw:iwidget id="com.example.ExampleWidget" supportedModes="view fullpage” mode="view” lang="en" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget" iScope="com.example.ExampleWidget"> <iw:resource uri="http://www.example.com/ExampleWidget.js" /> <iw:resource uri="http://www.example.com/ExampleWidget.css" /> <iw:content mode="view"> <![CDATA[ <div id="_IWID_widgetContent">Loading...</div> ]]> </iw:content> <iw:content mode="fullpage"> <![CDATA[ <div id="_IWID_widgetContent">Loading...</div> ]]> </iw:content> </iw:iwidget>

Page 8: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Widgets  –  iScope  dojo.provide("com.example.ExampleWidget"); dojo.declare("com.example.ExampleWidget", null, { constructor: function() {}, onLoad: function() {}, onView: function() {}, onEdit: function() {}, onFullpage: function() {}, onSearch: function() {} });

Page 9: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Widgets  –  declara=on  

Declara=vely  configured  using  widgets-­‐config.xml    <widgetDef defId="com.example.ExampleWidget” url="/ExampleWidget.xml" loginRequired="true” showInPallette=”true”> <itemSet> <item name="resourceId" value="{resourceId}" /> <item name="profilesCtx" value="{profilesSvcRef}" /> <item name="myProp" value="Abc123" /> </itemSet> </widgetDef>

Page 10: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Widgets  –  iContext  •  An  iContext  instance  is  set  into  the  iScope  instance  •  The  iContext  provides  access  to  the  widget  markup  (e.g.  root  

element),  I/O  related  func=ons  (i.e.  URL  rewri=ng),  widget  aNributes  etc.  

•  The  iContext  is  easily  accessed  from  the  iScope  class  using  this.iContext

•  Important  func=ons  include: –  iContext.getRootElement() : DOM Element –  iContext.getElementById(id:string) : DOM Element –  iContext.getiWidgetAttributes() : ItemSet –  iContext.getUserProfile() : ItemSet –  iContext.io.rewriteURI(uri:string) : string –  iContext.iEvents.fireEvent(name:string, type:string,

payload:object)

Page 11: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  

•  The  following  is  based  on  my  highly  acclaimed  (cough,  cough)  presenta=on  on  the  Ac=vity  Stream  

•  Much  more  detail  and  many  examples  there  •  See  hNp://slideshare.net/lekkim  

Mikkel  Flindt  Heisterberg    TwiNer:  @lekkim  E-­‐mail:  [email protected]  hNp://lekkimworld.com  hNp://slideshare.net/lekkim  

Page 12: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  

•  IS  – River  of  news  –  it’s  like  water  flowing  by  you  – No=fica=ons  about  ”stuff”  happening  in  (other)  systems  –  we  refer  to  these  no=fica=ons  as  entries  

•  ISN’T  – A  new  inbox  –  doesn’t  replace  email  – A  perpeptual  data  store  –  entries  are  deleted  based  on  a  server  defined  purge  interval  (default  is  30  days)  unless  saved  or  ac<onable  

Page 13: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  

•  In  my  opinion  it  makes  most  sense  to  not  consider  the  ac=vity  stream  as  one  single  stream  

•  Instead  think  that  – Each  user  has  his/her  own  (@me)  – There  is  a  public  stream  (@public)  – A  community  may  have  a  stream  if  the  widget  has  been  added  by  a  community  owner  –  if  there’s  no  stream  for  a  community  pos=ng  to  it  will  return  a  ”403  Forbidden”  

Page 14: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  •  You  will  mainly  use  the  POST  and  PUT  methods  to  send  JSON  data  (Content-­‐Type:  

applica=on/json)  to  the  API  

•  JSON  is  super  simple  key/value  data  format.  It  has  simple  datatypes  (strings,  numbers,  booleans),  objects  and  arrays  

{ ”email”: ”[email protected]”, ”niceGuy”: true, ”age”: 37, ”name”: { ”first”: ”Mikkel Flindt”, ”last”: ” Heisterberg” }, ”Connectospheres”: [6, 7, 8, 9, 10, 11, 12, 13, 14] }

Page 15: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  { "actor": {"id": "@me"}, "verb": "post", "title": "Some entry title", "updated": "2013-05-17T12:00:00.000Z", "object": { "title": "Some object title", "objectType": "note", "id": "1234567890-1234567890-1234567890" }

}

Page 16: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  hNps://<host>/connec=ons/opensocial/<auth>/rest/ac=vitystreams  

/<user  ID>/<group  ID>/<applica<on  ID>/<ac<vity  ID>  

Component   Meaning  

<auth>   (op<onal)  If  using  form  based  authen=ca=on  leave  this  component  out.  Otherwise  op=ons  are  anonymos,  basic,    oauth.  

<user  ID>   The  user  whose  stream  you’re  addressing  –  use  @me  for  current  users  stream,  @public  for  public  stream  or  a  community  ID  for  the  stream  in  a  community.  

<group  ID>   The  group  of  entries  you’re  addressing  –  use  @all  for  all  posts  or  op=ons  for  special  meaning  such  as  @saved,  @ac<ons,  @men<ons.  Refer  for  InfoCenter  and  resources  slide  for  more.    

<applica=on  ID>   When  retrieving  entries  this  refers  to  the  applica=on  (or  ”generator”)  that  created  the  entry.  All  the  IBM  Connec=ons  app  names  can  be  used  (profiles,  blogs,  wikis  etc.)  plus  custom  ones  (e.g.  on<megc).  @all  used  for  all  applica=ons.  

<ac=vity  ID>   Used  to  reference  a  specific  event  e.g.  for  upda=ng  saved  status.  

Page 17: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Ac=vity  Stream  

1.  /activitystreams/@me/@all List my (current users) entries

2.  /activitystreams/@public/@all List public stream entries

3.  /activitystreams/@me/@actions List my actionable events

4.  /activitystreams/@me/@saved/blogs List my saved events from blogs

5.  /@me/@all/@all/urn:lsid:lconn.ibm.com:activitystreams.story:bdb562f… Work with entry from my stream based on ID

* All URLs above start with https://<host>/connections/opensocial/<auth>/rest

Also used when creating new entries (e.g. POSTing)

Page 18: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Other  Programming  Interfaces  •  SPIs  are  lower-­‐level  programming  interfaces  which  may  be  subject  to  

modifica<on  from  release  to  release.    •  Event  SPI  

–  The  IBM  Connec=ons  Event  SPI  allows  third  par=es  to  consume  event  data  generated  by  IBM  Connec=ons.  

•  Seedlist  SPI  –  Use  the  Seedlist  service  provider  interface  (SPI)  provided  with  IBM  Connec=ons  to  

integrate  your  search  engine  with  IBM  Connec=ons  content.  

•  Service  SPI  –  You  can  use  the  IBM  Connec=ons  Service  SPI  to  learn  about  the  applica=ons  running  in  

your  IBM  Connec=ons  deployment.  

•  User  SPI  –  You  can  use  the  IBM  Connec=ons  User  SPIs  to  access  informa=on  about  the  users  in  

your  IBM  Connec=ons  deployment.  

Page 19: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Event  Handlers  –  declara=on  Declara=vely  configured  using  events-­‐config.xml    <postHandler enabled=”true" invoke="ASYNC" name=”MyEventHandler” class="com.example.MyEventHandler"> <subscriptions> <subscription source="*" type="*" eventName="*"/> <!-- <subscription source=”PROFILES" type="*" eventName=”profiles.updated"/> <subscription source=”PROFILES" type="*" eventName=”profiles.person.photo.updated"/> --> </subscriptions> </postHandler>

Page 20: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Event  Handlers  –  implementa=on  import com.ibm.connections.spi.events.EventHandler public class MyEventHandler implements EventHandler { public void init() throws EventHandlerInitException {} public void destroy() {} public void handleEvent(Event event) throws EventHandlerException { String eventName = event.getName(); // event name Person actor = event.getActor(); // person that triggered event // look at the event name if (event.getName().equals("profiles.person.photo.updated")) { // a profile photo was updated this.doEventProfilesPhotoUpdated(event); } else if (event.getName().equals("profiles.updated")) { // a profile was updated this.doEventProfilesUpdated(event); } } }

Page 21: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Event  Handlers  –  summary  

•  Make  event  handlers  asynchroneous  •  What  happens  if  your  event  handler  fail?  •  What  happens  if  the  recipient  of  the  event  (3rd  party  API)  fail?  

•  Be  defensive  –  consider  what  happens  if  events  are  lost  

Page 22: Social Connections VI Prague - An introduction to ibm connections as an appdev platform

Thank  you  

•  Presenta=ons  on  slideshare.net  –  this  one  is  coming  

•  Contact  me  –  ojen  =mes  more  than  willing  to  help  –  I’ll  let  you  know  when  it’s  a  project  J  

Mikkel  Flindt  Heisterberg    TwiNer:  @lekkim  E-­‐mail:  [email protected]  hNp://lekkimworld.com  hNp://slideshare.net/lekkim