Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to build a news aggregator site with Laravel and NewsAPI

How to build a news aggregator site with Laravel and NewsAPI

A talk on how to build a news aggregator site with Laravel and newsapi.org.

Live application: http://bit.ly/dept-news

GitHub Repo: http://bit.ly/newsapi-code

Tutorial: http://bit.ly/newsapi-article

Fisayo Afolayan

April 12, 2019
Tweet

More Decks by Fisayo Afolayan

Other Decks in How-to & DIY

Transcript

  1. Build a News Aggregator site with Laravel
    http://bit.ly/dept-news

    View Slide

  2. 01
    Dept - Backend Developers Meeting
    Agenda
    - What will we build?
    - How will we build it?
    - Brief architectural overview
    - Code walk-through

    View Slide

  3. 02
    Dept - Backend Developers Meeting
    What will we build?
    We will build a news aggregator website. A website that dispays news from
    multiple news sources.
    http://bit.ly/dept-news

    View Slide

  4. 03
    Dept - Backend Developers Meeting
    How will we build it?
    (laravel.com)
    - Laravel v5.8
    (newsapi.org)
    - NewsAPI
    News API is a simple and easy-to-use API that returns JSON metadata for headlines and
    articles live all over the web right now.
    The PHP Framework For Web Artisans.

    View Slide

  5. 04
    Dept - Backend Developer Meeting
    GET all news sources
    https://newsapi.org/v2/sources?&apiKey=insert_key_here
    GET :
    {

    "status": "ok",

    "sources": [

    {

    "id": "abc-news",

    "name": "ABC News",

    "description": "Your trusted source for breaking news, analysis, exclusive interviews, headlines, and videos at ABCNews.com.",

    "url": "https://abcnews.go.com",

    "category": "general",

    "language": "en",

    "country": "us"

    },

    {

    "id": "abc-news-au",

    "name": "ABC News (AU)",

    "description": "Australia's most trusted source of local, national and world news. Comprehensive, independent, in-depth analysis, the latest business, sport, weather and more.",

    "url": "http://www.abc.net.au/news",

    "category": "general",

    "language": "en",

    "country": "au"

    }

    }

    View Slide

  6. 05
    Dept - Backend Developers Meeting
    GET news from a news source
    {

    "status": "ok",

    "totalResults": 10,

    "articles": [

    {

    "source": {

    "id": "bbc-news",

    "name": "BBC News"

    },

    "author": "BBC News",

    "title": "Fake victim of Paris attacks jailed for one year",

    "description": "A restaurant manager falsely tried to claim victim's compensation for the 2015 Paris attacks.",

    "url": "http://www.bbc.co.uk/news/world-europe-47879648",

    "urlToImage": "https://ichef.bbci.co.uk/news/1024/branded_news/1835/production/_106379160_gettyimages-508599038.jpg",

    "publishedAt": "2019-04-10T11:52:53Z",

    "content": "Image copyrightAFPImage caption\r\n Mohamadi was rejected by the victim's fund after it decided he was not involved in any of the attacks\r\nThe manager of a
    restaurant caught up in the fatal Paris attacks of 2015 has been sentenced to prison for pretending he wa… [+2356 chars]"

    }

    }
    https://newsapi.org/v2/top-headlines?sources=bbc-news&apiKey=insert_key_here
    GET :

    View Slide

  7. 06
    Dept - Backend Developers Meeting
    Brief architectural overview & Code walk-through

    View Slide

  8. 07
    Dept - Backend Developers Meeting
    Questions?
    http://bit.ly/dept-news
    Live app
    Tutorial
    http://bit.ly/newsapi-article
    GitHub
    http://bit.ly/newsapi-code

    View Slide