Sitecore Item Web API & Mobile SDK

Post on 01-Jan-2016

83 views 0 download

Tags:

description

Sitecore Item Web API & Mobile SDK. 11 september 2013 Martijn van der Put. Inhoud. Sitecore Item Web Api Sitecore Mobile SDK Demo ParTech Blog Reader App. Wat is de Sitecore Item Web API. HTTP request Bewerken van content dmv item path, ID of query Response in JSON formaat. - PowerPoint PPT Presentation

Transcript of Sitecore Item Web API & Mobile SDK

www.partechit.nl

Sitecore Item Web API&

Mobile SDK

11 september 2013Martijn van der Put

www.partechit.nl

Inhoud• Sitecore Item Web Api

• Sitecore Mobile SDK

• Demo ParTech Blog Reader App

www.partechit.nl

Wat is de Sitecore Item Web API• HTTP request

• Bewerken van content dmv item path, ID of query

• Response in JSON formaat

www.partechit.nl

Installatie / configuratie• Sitecore 6.5 update 5 of hoger

• Web API Package– Sitecore.ItemWebApi.dll– Sitecore.ItemWebApi.config

www.partechit.nl

Site definitie uitbreiden in sitedefinitions.config

http://partech.local/-/item/v1/sitecore/shell%2Fsitecore%2Fcontent%2Fcorporate%2Fhome%2Fblog%2F2013%2F04%2Fsitecore%207%20in%2Ddepth%20indexing%20mechanics?scope=s&…

Installatie / configuratie (2)

www.partechit.nl

Sitecore.ItemWebApi.config

• Definitie van een nieuw veld in de Security Editor

• Default zijn de lees rechten “denied”

Installatie / configuratie (3)

www.partechit.nl

Query string parameters• http://<host_name>/-/item/v1/?<query string params>

– sc_itemid= – sc_itemversion=– sc_database=– language=– fields=– extractblob=1– payload=– scope=– query=– page= / pagezise=

www.partechit.nl

Mogelijke item bewerkingen• Ophalen van items (HTTP Get)

– Op basis van item IDhttp://<host_name>/-/item/v1/?sc_itemid={A60ACD61-A6DB-4182-8329-C957982CEC74}

– Query:http://<host_name>/-/item/v1/?query=/sitecore/content/*

– item path:http://<host_name>/-/item/v1/sitecore/content/home

www.partechit.nl

Mogelijke item bewerkingen (2)

JSON result

www.partechit.nl

Aanmaken nieuwe items

• HTTP Post• Querystring parameters:– template– name

OF– BranchID

http://<host_name>/-/item/v1/sitecore/Content/Home? name=MyItem&template=Sample/Sample Item&sc_database=master

Mogelijke item bewerkingen (3)

www.partechit.nl

Items bewerken

• HTTP Put

• HTTP Request header:Content-Type=application/x-www-formurlencoded

• Url aanmaken nieuwe items uitbreiden– <fieldName1>=<fieldValue1>&<fieldName2>=<fieldValue2>&<fieldNameN>=<fieldValueN>

– <fieldID1>=<fieldValue1>&<fieldID2>=<fieldValue2>&<fieldIDN>=<fieldValueN>

Mogelijke item bewerkingen (4)

www.partechit.nl

Item verwijderen

• HTTP Delete

• Heeft invloed op alle items in de scope

• Response toont aantal verwijderde items + ID

Mogelijke item bewerkingen (5)

www.partechit.nl

Media items aanmaken

• HTTP Post

• HTTP Request headerContent-Type=multipart/form-data

• Scope wordt niet gebruikt

• Context item is parent

Mogelijke item bewerkingen (6)

www.partechit.nl

Special requests• GetRenderingHtml

- sc_database- renderingId- sc_itemId

• http://<host_name>/<webapi_hook>/<special_request_hook>/<action_name>[?<optional_parameters>]

• http://<host_name>/-/item/v1/-/actions/GetRenderingHtml?sc_database=master&language=en&renderingId={493B3A83-0FA7-4484-8FC9-4680991CF743}&sc_itemid={110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}&a=1&b=2&c=3

www.partechit.nl

Uitbreidbaarheid• Item Web Api functies gebruiken pipelines• Pipelines zijn uit te breiden of toe te voegen

www.partechit.nl

Wanneer te gebruiken• Vanuit andere applicaties content tonen of

bewerken

• Mobile Apps -> directe aanroep -> via Sitecore Mobile SDK

www.partechit.nl

Item Web API vs Sitecore Visual ServiceItem Web Api Visual Service

overlap

HTTP request SOAP

Uitbreidbaarheid door pipelines override of eigen pipelines toevoegen

Uitbreidbaarheid door nieuwe webservice* of huidige service overriden

Uitgebreidere authorisatie mogelijk Standaard Sitecore authorisatie

Sitecore query Item ID

www.partechit.nl

Sitecore Mobile SDK

www.partechit.nl

Wat is de Mobile SDK• Framework iOS based applicaties

• Server: Item Web Api

• Client: SitecoreMobileSDK.framework met Objective-C Api

www.partechit.nl

Benodigdheden• Sitecore 6.5 (update-5) of later

• Sitecore Item Web Api

• Sitecore Mobile SDK framework bundle

• OS X met Xcode software

www.partechit.nl

Installatie / Configuratie• Item Web Api

• Framework bundle toevoegen

• Linken van extra Frameworks

• Linken van extra libraries

www.partechit.nl

4 soorten apps• Embedded Browser

– “inframen” mobiele website variant

• Item Web Api– Native objective-C code icm Sitecore Mobile SDK Framework

• Hybrid– Combinatie embedded browser en Native objective-C

• Custom approach– met eigen Objective-C Api

www.partechit.nl

Communicatie SDK <> Item Web API

www.partechit.nl

ParTech Blog Reader app

www.partechit.nl

Datacontroller

www.partechit.nl

Code explanation• Ophalen van een lijst met blogItems (titel, datum, introductie, tekst, auteur)

• SCApiContext

www.partechit.nl

Code explanation (2)

• SCAsyncOp block

request

callback

www.partechit.nl

Code explanation (3)

• SCItem object

www.partechit.nl

Code explanation (4)

• Veld uitlezen uit target-item

www.partechit.nl

Code explanation (5)

• Result object vullen

www.partechit.nl

Code explanation (6)

• Item aanmaken

www.partechit.nl

Code explanation (7)

• Item aanmaken en bewerken

www.partechit.nl

Caching en Request merging• Hergebruik van items indien in de cache

• Sitecore query altijd gelezen uit backend

• SCItemsReaderRequestIgnoreCache flag

• Mergen van requests: aantal calls verminderd

www.partechit.nl

Andere mogelijkheden Mobile SDK• Ophalen van paged items• Verwijderen van items• Uploaden van Media Files• Html ophalen van Renderings• Analytics integratie

www.partechit.nl

Korte demo

www.partechit.nl

Nuttige resources• iOS Developer Library

http://developer.apple.com

• Sitecore GitHubhttps://github.com/Sitecore/sitecore-ios-sdk

• Alexander DodatkoDeveloper Sitecore Mobile Team

www.partechit.nl

Conclusie

www.partechit.nl

Mail: martijn@partechit.nl

Twitter: @Martijnvdput