php

Build a topic page

By vineet

Problem

You want to build a page about someone like Barack Obama or Steve Jobs or some organization like Google or NBA.

Topics are pre-defined people, organizations, places, diseases, issues, events and products in the daylife eco-system.

Things you can put on a topic page:

 

 

Read more below to see the code (in PHP) that builds this page.

PHP: Client to make multiple DayPI calls as one request using the Batch API

By vineet

The Batch API lets you make multiple DayPI requests as one request to the daylife servers.

You can use this PHP client to make a Batch.parallel request. You can download this script from the attachment below.

Here is sample code how to use this script to first form your DayPI requests and then provide them as request to the Batch API:

RSS feed for Articles about any term using DayPI Search

By sumit_kataria

I have written a PHP script that generates RSS feeds for articles by calling Daylife's search APIs for any topic, queries, tags or events happening in the world.

Each item in the RSS feeds contains an article headline, description, published time and link to the original source of the article. To produce a desired RSS feed of your interest, you can use the script that I have hosted by forming a URL that looks like:

http://www.buzzingblog.com/dayliferss/rss.php?query=<search term of your choice>

For e.g.,

http://www.buzzingblog.com/dayliferss/feed.php?query=Barack%20Obama

Read more about Daylife's Search query syntax to form your queries intelligently.

You can also specify the number of items you want to pull in the feed using a limit parameter. So your final URL will looks like

http://www.buzzingblog.com/dayliferss/feed.php?query=Barack%20Obama&limit=20

The last parameter that the script allows is source_filter_id. Read more about source filters here to learn how you can restrict your search to a limited number of sources.

With the availability of RSS feeds on top of the Daylife API, opportunities to build news applications are endless. The script calls the Daylife API on every request and builds the RSS feed in real time. Webmasters can use RSS generator to produce feeds on desired topics to feed them their Drupal/Joomla or any other RSS supported content management systems.

You can download the script and run it on your own server, in case, you want to customize it. You will need to substitute your own accesskey and shared secret that you received from Daylife to make the script work.

Build a customized index widget

By vineet

 

Indexes help you create fun widgets to keep track of the coverage that topics of your interest are getting. The Index Creator in our labs section helps your create an index widget in few minutes with upto 12 topics/queries that you care about.

However, if you want an index widget with more customizations, you can use our News Indexer code to generate the data files for such a widget. Some examples of these customizations could be a an index with

  • more than 12 items (for e.g., CNNMoney's Meme-o-meter Index) OR
  • restrict the results to a particular set of sources (for e.g. Cruisedex restricts the results to travel sources only) OR
  • build an index with different durations to compare (for e.g. last month/this month index)

Remember, this code lets you generate the XML data files for an index widget. You will have to then build the UI for the widget that consumes this XML.

 

 

Drupal: Add a block with headines about anything you want

By vineet

Drupal is one of the most popular content management systems along with Wordpress and Joomla.


This basic DayPI drupal module lets you create a block with headlines about any topic you want. You can also host a search page that lets any user to search news from around the web on your website.

The Communication Initiative (The CI) network is an online space for sharing the experiences of, and building bridges between, the people and organisations engaged in or supporting communication as a fundamental strategy for economic and social development and change. They use this drupal module to present recent news about areas of their interest in the right navigation bar of their site.

 

A Lightweight PHP Client Library

By john

The PHP sample below provides a sample client library to consume the daylife APIs. We have demonstrated integration with a single API call - search_getRelatedArticles.

Download it here

Test it here

The code below provides hooks to receive json encoded response objects from the daylife API. It does NOT use the XML encoded response.

Render a set of headlines using PHP

By john

Overview

The sample below shows how to render a set of headlines matching a hard coded search term.

Download it here

Test it here

Code to Rig Up a News Index

By john


This news indexer sample is what we use to power the indexer widgets for Treehugger and CNN's Meme-o-meter

A Topic Page Builder

By john

This php sample demonstrates how you can make daypi calls to get stories, images, quotes and connections for a given topic name or a topic id.