SlideShare a Scribd company logo
1 of 18
Download to read offline
Drupal Content API
     August 2012



                   Matthew Wetmore
                   mattwetmore.com
                        @mwetmore
About Me
● Matt Wetmore
  ○ Mattwetmore.com
  ○ Currently work at ING U.S. in Windsor, CT
  ○ Using Drupal for 2.5 years
  ○ Twitter: @mwetmore
  ○ Central CT Drupal Meetup Organizer




                                          Matthew Wetmore
                                          mattwetmore.com
                                               @mwetmore
About This Session

 ● Who is this session for?
   ○ Developers and Site Builders
 ● What modules will we cover?
   ○ Services (http://drupal.org/project/services/)
   ○ Content API (http://drupal.org/project/contentapi)
 ● What version of Drupal and other things
   ○ I'll be using D7, however, Services and Content API are
     available for D6.
   ○ Some quick code examples of actually using the API are
     written in JQuery.



                                           Matthew Wetmore
                                           mattwetmore.com
                                                @mwetmore
More Than The Web

● Todays Content
  ○ Web
  ○ Mobile
  ○ Apps
  ○ Tablets
  ○ Readers
● Where does it all come from
  ○ Users, Companies, other Sites and systems
● How do you provide your content to all of the mediums that
  your visitors use.



                                            Matthew Wetmore
                                            mattwetmore.com
                                                 @mwetmore
Repositories and COPE

 ● Content Repositories are nothing new.
   ○ Organized content into structured pieces.
   ○ Contained Meta Data fields to structure it
   ○ Allowed the repository to be queried for specific items.
 ● COPE : Create Once Publish Everywhere
   ○ NPR Model
   ○ Lets create content in once place and use it everywhere
   ○ http://blog.programmableweb.com/2009/10/13/cope-
     create-once-publish-everywhere/
   ○ Reduces amount of duplicate content
   ○ Reduces the amount of incorrect data in other places.


                                             Matthew Wetmore
                                             mattwetmore.com
                                                  @mwetmore
Matthew Wetmore
mattwetmore.com
     @mwetmore
How does this related to Drupal

 ● Believe it or not Drupal is setup to do some of this today.
   ○ CCK (Allows us to create different content types for
       different reasons)
   ○ Services & Content API (Allows you to connect and pull
       content out)
   ○ Views (Allows you to build pages of different content)
   ○ Panels (Compile content piences into one page)
 ● Although D7 compiles and entire page and delivers it to the
   user, D8 should split the presentation and data layers to
   provide easier access to the underlying content.



                                             Matthew Wetmore
                                             mattwetmore.com
                                                  @mwetmore
Enter the Content API Module

 ● Content API Module
   ○ URL: http://drupal.org/project/contentapi
   ○ Created for the FCC by Seabourne Inc
 ● What it does
   ○ Runs on top of Services to provide a query based
     interface to access content in Drupal.
   ○ With Services, content is exposed as XML, JSON,
     JSONP, RSS, YAML
   ○ This is a Read Only process.
   ○ Can be accessed anonymously.



                                           Matthew Wetmore
                                           mattwetmore.com
                                                @mwetmore
Wait a Second
                ● I know what you are thinking...
                   ○ Doesn't the Services module
                      already allow you to do this?
                       ■ Yes, but not as easily,
                          such as providing a
                          query interface to the
                          content.
                       ■ Services will also allow
                          Create and Delete
                          actions, while Content
                          API just allows Read
                          Actions.




                               Matthew Wetmore
                               mattwetmore.com
                                    @mwetmore
Configuring Services

 ●   Download / Enable Content API First
 ●   Download / Enable Services Module
 ●   Create a new endpoint as a REST Server
 ●   Under Resources, enable Content.
 ●   Save

Lets give this a try.




                                              Matthew Wetmore
                                              mattwetmore.com
                                                   @mwetmore
Configuring Content API

 ●   Select which core node fields should be available.
 ●   Configure the limit to return.
 ●   Select Node Type, Sort Order, etc.
 ●   Specific fields can then be selected within each content
     type.


Lets give this a try.




                                                Matthew Wetmore
                                                mattwetmore.com
                                                     @mwetmore
Using Content API Direct - Part 1

 ● Default Configuration
   ○ http://site-name/api/content
      ■ This will return the last 10 nodes.
   ○ http://site-name/api/content/[nid]
      ■ This will return a specific node.


Lets give this a try.




                                              Matthew Wetmore
                                              mattwetmore.com
                                                   @mwetmore
Using Content API Direct - Part 2
Parameters:
●   search_string=[test] Matches the string [test] against node titles
●   type=[type] Returns only a single node type
●   types[]=[type] Returns only the input node types types[]=blog&types[]=page
●   terms[]=[term id] Returns nodes labeled with any of the input terms
●   title=[title] Returns a node with an exact title match
●   created_before=[YYYY-MM-DD] Inclusive. Returns nodes created before the input date
●   created_after=[YYYY-MM-DD] Inclusive. Returns nodes created after the input date
●   changed_before=[YYYY-MM-DD] Inclusive. Returns nodes updated before the input date
●   changed_after=[YYYY-MM-DD] Inclusive. Returns nodes updated after the input date
●   fields=all Show all fields for a node, includes CCK, body, taxonomy etc.
●   fields[]=[field] The fields parameter can instead be an array of the fields you want returned. For example
    fields[]=nid&fields[]=title will only return the node's nid and title.

CCK Queries:
Any field can be queried by using field_[field name]=[value]. Example: /api/content?field_coauthor=jason will
return all nodes with a cck coauthor field containing the value “jason.” Note that only exact matches are currently
support for CCK queries.

       ○

Lets give this a try.                                                              Matthew Wetmore
                                                                                   mattwetmore.com
                                                                                        @mwetmore
Using Content API Direct - Part 3
Lets give this a try.

Examples:

http://mw.dev/repository/radio/xml/content?terms[tags]=7
http://mw.dev/repository/radio/xml/content?field_show_day=tuesday
http://mw.dev/repository/radio/json/content?type=radio_show
http://mw.dev/repository/radio/json/content/15
http://mw.dev/repository/radio/xml/content/15
http://mw.dev/repository/radio/xml/content?field_show_station=1041
http://mw.dev/repository/radio/json/content?field_show_station=925




                                                            Matthew Wetmore
                                                            mattwetmore.com
                                                                 @mwetmore
Ways to use it
●   Other Web Pages
    ○   You can build simple widgets to display specific content
●   Other Web Apps
    ○   Use Drupal content in Ruby, or Java, or other apps.
●   Mobile Apps
    ○   Mobile apps consist of content similar to your website, why not source it from
        the same location




                                                              Matthew Wetmore
                                                              mattwetmore.com
                                                                   @mwetmore
Quick Web Page Example




                         Matthew Wetmore
                         mattwetmore.com
                              @mwetmore
Quick Web Page Example
●   mattwetmore.com is the base site, and it just a quick HTML page built off of
    Skeleton boilerplate.
●   Jquery is used to make requests to the repository.
●   The Drupal repository is located at http://mattwetmore.com/repository
●   The entire page, including Tweets and Instagram are just other jquery json
    requests to each of those services to pull the content in.
●   Example JSon request to the content API.
    ○     $.getJSON("/repository/api/json/content/3", function(data){
           $('#bio').empty();
           $('#bio').append(data.body[0].value);
        });
●   This is a simple solution because it is on the same domain, cross-domain is trickier
    but it can be done.

                                                                Matthew Wetmore
                                                                mattwetmore.com
                                                                     @mwetmore
Thank You!
Any Questions?

If you are from CT, can you please take the CT Drupal
Meetup Survey?

bit.ly/RWsfvv
Also, be sure to follow the CT Drupal twitter account:
@ctdrupal


                                            Matthew Wetmore
                                            mattwetmore.com
                                                 @mwetmore

More Related Content

Similar to Drupal Content API - DCCT 2012

Introduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedIntroduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedImran Sayed
 
How QCLean Works? Introduction to Browser Extensions
How QCLean Works? Introduction to Browser ExtensionsHow QCLean Works? Introduction to Browser Extensions
How QCLean Works? Introduction to Browser ExtensionsQing-Cheng Li
 
Extending WordPress' TinyMCE
Extending WordPress' TinyMCEExtending WordPress' TinyMCE
Extending WordPress' TinyMCEHristo Chakarov
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Matt Hamilton
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Phase2
 
Manila MuleSoft Meetup - September 2018
Manila MuleSoft Meetup - September 2018Manila MuleSoft Meetup - September 2018
Manila MuleSoft Meetup - September 2018Ryan Anthony Andal
 
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8Wong Hoi Sing Edison
 
Boston Startup School - OO Design
Boston Startup School - OO DesignBoston Startup School - OO Design
Boston Startup School - OO DesignBryan Warner
 
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery Fadi Nicolas Zahhar
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteTaylor McCaslin
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalRod Martin
 
From prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.ioFrom prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.ioMáté Lang
 
Lesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ayLesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ayCodecademy Ren
 
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirstBuilding CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirstJun-ichi Sakamoto
 
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...Shekh Muenuddeen
 

Similar to Drupal Content API - DCCT 2012 (20)

Introduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedIntroduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran Sayed
 
How QCLean Works? Introduction to Browser Extensions
How QCLean Works? Introduction to Browser ExtensionsHow QCLean Works? Introduction to Browser Extensions
How QCLean Works? Introduction to Browser Extensions
 
Extending WordPress' TinyMCE
Extending WordPress' TinyMCEExtending WordPress' TinyMCE
Extending WordPress' TinyMCE
 
Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009Lipstick on a Pig - European Plone Symposium 2009
Lipstick on a Pig - European Plone Symposium 2009
 
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
Drupal 8, Don’t Be Late (Enterprise Orgs, We’re Looking at You)
 
Drupal
DrupalDrupal
Drupal
 
Manila MuleSoft Meetup - September 2018
Manila MuleSoft Meetup - September 2018Manila MuleSoft Meetup - September 2018
Manila MuleSoft Meetup - September 2018
 
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8
[HKDUG] #20160626 - HKOSCon 2015 - Website DIY with Drupal 8
 
Boston Startup School - OO Design
Boston Startup School - OO DesignBoston Startup School - OO Design
Boston Startup School - OO Design
 
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery
Word press beirut December 4 Meetup - Gutenberg VS WP-Bakery
 
Web Components
Web ComponentsWeb Components
Web Components
 
Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress Multisite
 
Absolute Beginners Guide to Drupal
Absolute Beginners Guide to DrupalAbsolute Beginners Guide to Drupal
Absolute Beginners Guide to Drupal
 
From prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.ioFrom prototype to production - The journey of re-designing SmartUp.io
From prototype to production - The journey of re-designing SmartUp.io
 
Lesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ayLesson 101 23 aug13-1430-ay
Lesson 101 23 aug13-1430-ay
 
Twig in the Wild
Twig in the WildTwig in the Wild
Twig in the Wild
 
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirstBuilding CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
 
Web components
Web componentsWeb components
Web components
 
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...
Ahmadabad mule soft_meetup_05june2021_mule4_automate mulesoft on prem servers...
 
Dust.js
Dust.jsDust.js
Dust.js
 

Recently uploaded

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Drupal Content API - DCCT 2012

  • 1. Drupal Content API August 2012 Matthew Wetmore mattwetmore.com @mwetmore
  • 2. About Me ● Matt Wetmore ○ Mattwetmore.com ○ Currently work at ING U.S. in Windsor, CT ○ Using Drupal for 2.5 years ○ Twitter: @mwetmore ○ Central CT Drupal Meetup Organizer Matthew Wetmore mattwetmore.com @mwetmore
  • 3. About This Session ● Who is this session for? ○ Developers and Site Builders ● What modules will we cover? ○ Services (http://drupal.org/project/services/) ○ Content API (http://drupal.org/project/contentapi) ● What version of Drupal and other things ○ I'll be using D7, however, Services and Content API are available for D6. ○ Some quick code examples of actually using the API are written in JQuery. Matthew Wetmore mattwetmore.com @mwetmore
  • 4. More Than The Web ● Todays Content ○ Web ○ Mobile ○ Apps ○ Tablets ○ Readers ● Where does it all come from ○ Users, Companies, other Sites and systems ● How do you provide your content to all of the mediums that your visitors use. Matthew Wetmore mattwetmore.com @mwetmore
  • 5. Repositories and COPE ● Content Repositories are nothing new. ○ Organized content into structured pieces. ○ Contained Meta Data fields to structure it ○ Allowed the repository to be queried for specific items. ● COPE : Create Once Publish Everywhere ○ NPR Model ○ Lets create content in once place and use it everywhere ○ http://blog.programmableweb.com/2009/10/13/cope- create-once-publish-everywhere/ ○ Reduces amount of duplicate content ○ Reduces the amount of incorrect data in other places. Matthew Wetmore mattwetmore.com @mwetmore
  • 7. How does this related to Drupal ● Believe it or not Drupal is setup to do some of this today. ○ CCK (Allows us to create different content types for different reasons) ○ Services & Content API (Allows you to connect and pull content out) ○ Views (Allows you to build pages of different content) ○ Panels (Compile content piences into one page) ● Although D7 compiles and entire page and delivers it to the user, D8 should split the presentation and data layers to provide easier access to the underlying content. Matthew Wetmore mattwetmore.com @mwetmore
  • 8. Enter the Content API Module ● Content API Module ○ URL: http://drupal.org/project/contentapi ○ Created for the FCC by Seabourne Inc ● What it does ○ Runs on top of Services to provide a query based interface to access content in Drupal. ○ With Services, content is exposed as XML, JSON, JSONP, RSS, YAML ○ This is a Read Only process. ○ Can be accessed anonymously. Matthew Wetmore mattwetmore.com @mwetmore
  • 9. Wait a Second ● I know what you are thinking... ○ Doesn't the Services module already allow you to do this? ■ Yes, but not as easily, such as providing a query interface to the content. ■ Services will also allow Create and Delete actions, while Content API just allows Read Actions. Matthew Wetmore mattwetmore.com @mwetmore
  • 10. Configuring Services ● Download / Enable Content API First ● Download / Enable Services Module ● Create a new endpoint as a REST Server ● Under Resources, enable Content. ● Save Lets give this a try. Matthew Wetmore mattwetmore.com @mwetmore
  • 11. Configuring Content API ● Select which core node fields should be available. ● Configure the limit to return. ● Select Node Type, Sort Order, etc. ● Specific fields can then be selected within each content type. Lets give this a try. Matthew Wetmore mattwetmore.com @mwetmore
  • 12. Using Content API Direct - Part 1 ● Default Configuration ○ http://site-name/api/content ■ This will return the last 10 nodes. ○ http://site-name/api/content/[nid] ■ This will return a specific node. Lets give this a try. Matthew Wetmore mattwetmore.com @mwetmore
  • 13. Using Content API Direct - Part 2 Parameters: ● search_string=[test] Matches the string [test] against node titles ● type=[type] Returns only a single node type ● types[]=[type] Returns only the input node types types[]=blog&types[]=page ● terms[]=[term id] Returns nodes labeled with any of the input terms ● title=[title] Returns a node with an exact title match ● created_before=[YYYY-MM-DD] Inclusive. Returns nodes created before the input date ● created_after=[YYYY-MM-DD] Inclusive. Returns nodes created after the input date ● changed_before=[YYYY-MM-DD] Inclusive. Returns nodes updated before the input date ● changed_after=[YYYY-MM-DD] Inclusive. Returns nodes updated after the input date ● fields=all Show all fields for a node, includes CCK, body, taxonomy etc. ● fields[]=[field] The fields parameter can instead be an array of the fields you want returned. For example fields[]=nid&fields[]=title will only return the node's nid and title. CCK Queries: Any field can be queried by using field_[field name]=[value]. Example: /api/content?field_coauthor=jason will return all nodes with a cck coauthor field containing the value “jason.” Note that only exact matches are currently support for CCK queries. ○ Lets give this a try. Matthew Wetmore mattwetmore.com @mwetmore
  • 14. Using Content API Direct - Part 3 Lets give this a try. Examples: http://mw.dev/repository/radio/xml/content?terms[tags]=7 http://mw.dev/repository/radio/xml/content?field_show_day=tuesday http://mw.dev/repository/radio/json/content?type=radio_show http://mw.dev/repository/radio/json/content/15 http://mw.dev/repository/radio/xml/content/15 http://mw.dev/repository/radio/xml/content?field_show_station=1041 http://mw.dev/repository/radio/json/content?field_show_station=925 Matthew Wetmore mattwetmore.com @mwetmore
  • 15. Ways to use it ● Other Web Pages ○ You can build simple widgets to display specific content ● Other Web Apps ○ Use Drupal content in Ruby, or Java, or other apps. ● Mobile Apps ○ Mobile apps consist of content similar to your website, why not source it from the same location Matthew Wetmore mattwetmore.com @mwetmore
  • 16. Quick Web Page Example Matthew Wetmore mattwetmore.com @mwetmore
  • 17. Quick Web Page Example ● mattwetmore.com is the base site, and it just a quick HTML page built off of Skeleton boilerplate. ● Jquery is used to make requests to the repository. ● The Drupal repository is located at http://mattwetmore.com/repository ● The entire page, including Tweets and Instagram are just other jquery json requests to each of those services to pull the content in. ● Example JSon request to the content API. ○ $.getJSON("/repository/api/json/content/3", function(data){ $('#bio').empty(); $('#bio').append(data.body[0].value); }); ● This is a simple solution because it is on the same domain, cross-domain is trickier but it can be done. Matthew Wetmore mattwetmore.com @mwetmore
  • 18. Thank You! Any Questions? If you are from CT, can you please take the CT Drupal Meetup Survey? bit.ly/RWsfvv Also, be sure to follow the CT Drupal twitter account: @ctdrupal Matthew Wetmore mattwetmore.com @mwetmore