GithubHelp home page GithubHelp logo

devabuse / tvdbapi Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 8 KB

This is based on my default template for connecting with external API's. I have implemented a few methods from the TVDB api and offer that up as a base for anyone who wants to continue working on it.

PHP 100.00%

tvdbapi's Introduction

TVDB api

This is based on my default template for connecting with external API's. I have implemented a few methods from the TVDB api and offer that up as a base for anyone who wants to continue working on it.

Below is a description of the components used as well. Inside the repository are also a number of example files that can be used. Of course to use any of these you need to get your own API key.

Credentials

I always seperate the credentials used for authentication in it's own class. The reason for this is because credentials can come from many different places like a settings.ini file(this is the method I use in the provided examples), a php file or even a cloud service like vault.

settings.ini file

apikey = ''

Authentication

The authentication class requires the credentials class to do an actual authentication request. This can be anything ranging from oauth to a simple curl request depending on the API. I want to encapsulate that logic in it's own class.

Requests

A request will always require an Authentication object and a Client (i tend to go with Guzzle). The Request is a base class that can't really run on it's own because it requires methods from classes that extend it to function. The Request class is really nothing more than a holder for the paramaters that depends on a few abstract methods to connect Authentication and Client together.

If we then take a look at RequestSearch you can see that it extends Request and implements an interface. These classes(RequestSearch, RequestSeries and RequestSeriesEpisodes) are very small in setup, because all they have to do now is tell which API call to execute, what method to use and which paramaters are required by default.

In this way all you need to do know to implement all of the remaining api callbacks provided by tvdb is to add more Request classes that match up with their API. I have found from past experience that a setup like this is easy to extend and work with from a team perspective.

tvdbapi's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.