Skip to content

Latest commit

 

History

History

backend

DataScouts API

API for Social Media Aggregator

Introduction

Hello, welcome onboard.

<<<<<<< HEAD This project designed on #oSoc17 is a little API to fetch data from different social medias for specific handles. In short words, APi for Social Media Aggregator.

This document purpose is to give an overview about this project and all basic steps before use or work on it.

This project design on #oSoc17 is a little API to fetch data from different social media for specified handle. In short words, APi for Social Media Aggregator.

This document purpose is to give an orverview about this project and necessary steps before working on it.

4bd3f12871579427fa6bb824cbe9dc12a2fcaf55

Table of contents

Technologies

This API exploits the following technologies :

Name Description More infos
Lumen v5.4 Fast micro-framework by Laravel Site web
PHP Laravel v5.4 PHP FrameWork for Web Artisans Site web
Composer v1.5 Dependency Manager for PHP Site web, Download

Requirements

  • All technologies, listed above, are necessary.
  • This project was build with PHP v7.0, your PHP environment must set to it.
  • A connection to a DB to store entities, handles, providers and feeds for further analyse.

Installation

Get Started

    # Grab the repository
    $ git clone https://github.com/oSoc17/datascouts.git

    # Move to the datascouts/backend directory
    $ cd datascouts/backend

    # Install dependencies
    $ composer install --no-dev

Configure

After installed all dependencies, you need to configure the application before running it. To do so, copy the env.example.

    # Copy and rename the .env.example
    $ copy .env.example .env

Open the .env file.

Application key

I strongly recommand to change your APP_KEY to some random string. Typically, this string should be 32 characters long. If the application key is not set, your user encrypted data will not be secure !

Database

All info required to make a sucessful connection to the database have to be input in the config at the corresponding.

    DB_HOST=
    DB_PORT=
    DB_DATABASE=
    DB_USERNAME=
    DB_PASSWORD=

Finally, execute the following command to create the tables.

    # Copy and rename the .env.example
    $ php artisan migrate --force

Twitter App

You need to create an application and create your access token in the Developer Twitter Application Management.

    TWITTER_APP_ID= {Consumer Key (API Key)}
    TWITTER_APP_SECRET= {Consumer Secret (API Secret)}
    TWITTER_APP_ACCESS_TOKEN= {Access Token}
    TWITTER_APP_ACCESS_TOKEN_SECRET= {Access Token Secret}

Vimeo App

You need to create an application and generate your access token in the Developer Vimeo Application Management

    VIMEO_APP_ID= {Client Identifier}
    VIMEO_APP_SECRET= {Client Secrets}
    VIMEO_APP_ACCESS_TOKEN={Generated access token}
    

Youtube App

In order to get an API Key, you will

  1. Need to create an project on Google Console Developer
  2. Add & Active Youtube Data API v3.
  3. Finally, create credentials and generate API_KEY to access Youtube API
    YOUTUBE_API_KEY= {APi Key}

Run

    # Run localy at http://0.0.0.0:8080
    $ php -S 0.0.0.0:8080 -t ./public/
    
    # Now, let's test that API
    # Open this URL in a browser : http://0.0.0.0:8080/api/v1/zen 

    # To run in production :
    # On the Nginx file for the site dedicated to this APi,
    # make sure to redirect to the folder public/index.php

Routes

Base url : /api/v1

All routes must be prefixed with this base url. For instance, to get all entities https://example.com/api/v1/entities

Formats of objet send and return by this API

Endpoints

Entity Resource

Entity Resource

Handle Resource

Service Resource

Feed Resource

Provider Resource

Commands

Two commands have been created for this project. They can only be executed on root path of the backend folder.

DataScoutsAddAdminUser : datascouts:add-admin

This command can be used to create an user with role set to admin. It has the following syntax :

    php artisan datascouts:add-admin fullname [--email=...] [--password=...]
  • fullname: [REQUIRED] The user fullname, by default 'R00t'
  • email: [REQUIRED] The user email
  • password : The user password. If not set, can be auto-generated. Will, in any case, be hashed before store in DB.

DataScoutsFetchHandles : datascouts:fetch-handles

This command fetches the social media data related to the specific handles. It has the following syntax :

    php artisan datascouts:fetch-handles [--only=...]
  • only: [REQUIRED] Will only fetch for the specified handle by it ID

Development

Enhancements