際際滷

際際滷Share a Scribd company logo
7
                                      drupal




Importing and syncing
content using Feeds

Peter Vanhee
2nd October 2011 - DrupalCamp Spain
Who am I?

 Consumer and contributor to Drupal for
  over 5 years
 Co-founder Youth Agora @youthagora
  and Nuvole @nuvoleweb
 Web consultant in Barcelona @pvhee
www.europeancampus.eu
Importing and synchronizing content using Feeds
Content is aggregated and synchronized using Feeds
Use Cases

 Build Activity streams using feeds from
  Twitter, Facebook, ...
 Batch import sets of users from 鍖le
 Import Commerce Products
 ...
What is Feeds?
Feeds is...

 Import / aggregate framework
 Create and update drupal entities out of
  the box: nodes, users, taxonomy
 Real-time feeds support
Related


 Migrate            Aggregator
 Table Wizard
 User import
 Node import
Feeds as the standard for piping content
Feeds usage


               drupal 6



                  drupal 7




              statistics from drupal.org
                Statistics from drupal.org
Fetcher

 Parser

Processor
Fetcher


 Http
 File upload




                     A complete list is at http://drupal.org/node/856644
Parser
 CSV, RSS1, RSS2, Atom
 OPML, Sitemap XML
 XPath for XML/HTML
 JSONPath for JSON
 YouTube, Flickr, 際際滷share
 iCal

                        A complete list is at http://drupal.org/node/856644
Processor

 Node
 User
 Taxonomy
 Commerce Products



                      A complete list is at http://drupal.org/node/856644
2011.drupalcamp.es   my drupal site

      Example #1
Import and sync RSS Feeds
Feeds importers are con鍖gurations of
  Fetcher      Parser     Processor
Importing and synchronizing content using Feeds
Importing and synchronizing content using Feeds
Importing and synchronizing content using Feeds
create nodes of type Feed item
鍖elds in RSS   鍖elds in Feed item
And now... importing!
/import
Importing and synchronizing content using Feeds
We can do this with Drupal Core Aggregator too!
Lets try spawning
                                 Feed A

                        User 1   Feed B
              Feed A

    User      Feed B             Feed C
              Feed C
1

                        User 2   Feed X
    Aggregator (core)                 Feeds
Spawning
Add Feed = Add Node
Example #2
Import   images
A node of type Story will hold a Flickr image
the Flickr XML feed




{   http://www.鍖ickr.com/services/feeds/geo?format=rss_200&tags=drupalcamp
Parse XML with XPath expressions

              //item
               title
               link
        description




            geo:lat
           geo:long



media:thumbnail/@url
Fetcher             http



 Parser         XPath Parser


            Map targets from XPath
Processor      Node processor
select XPath XML parser
source is XPath Result   鍖elds in Story
Importing and synchronizing content using Feeds
Importing and synchronizing content using Feeds
Importing
Importing and synchronizing content using Feeds
We have problems



        !
     Tags are not imported correctly
Feeds Tamper




     http://drupal.org/project/feeds_tamper
Enter Tampering
  Input Field                    Output Field
                       explode
drupal feeds sevilla             drupal
                                 feeds
                                 sevilla
                 html_encode
Me&lt;/a&gt;posted a        <a href=.>Me</a>
  photo:&lt;/p&gt;            posted a photo
Con鍖gure Tampering
More tamper actions
Add your own tamper plugins




            snippet from html_entity_decode.inc
After importing... tags are now
        correctly split
Importing Big Stuff

 Feeds has Batch support
 Feeds can run on cron jobs in the
  background
Field support
   Text        Email
   File        Multimedia
   Image       Address
   Link
   Geo鍖eld
   Taxonomy   Tip: check Feeds issue
   Password   queues for patches
   Date
   Integer
Feeds as a Framework
 Supports import/sync of Commerce
  Products (via Commerce Feeds)
 Straightforward to add custom fetchers,
  patchers and processors using Feed
  hooks (check feeds.api.php)
Finally...
when not to use Feeds


 Content does not need to be stored by
  Drupal
 Complex content migration tasks
Now... Real-Time?
                        Are we there yet?
                        Are we there yet?
                        Are we there yet?



Publisher                                     Subscriber
   Yes. Here you are.


                        Are we there yet?


                                     際際滷 taken from @alexb presentation on Feeds
Enter PubSubHubBub


Publisher          Hub           Subscriber

 What does this solve?
 1. Noti鍖cations to Subscribers managed by Hub
 2. Send only what is changed and when it gets
 changed
Euhm.. so what does
         Feeds do exactly?

  Feeds makes Drupal a PSHB
         Subscriber

Update feeds in real-time from PSHB Hubs
       e.g. Blogger, Wordpress, Superfeedr, ...
Thanks!


          Peter Vanhee
          @pvhee
Questions?


             Peter Vanhee
             @pvhee

More Related Content

Importing and synchronizing content using Feeds