Coder Social home page Coder Social logo

jmsche / api-allocine-helper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from etn406/api-allocine-helper

0.0 1.0 0.0 44 KB

l'API Allociné Helper est un script PHP permettant d'utiliser l'API d'Allociné : récupérez facilement les informations sur les films, les séries TV, les stars, etc. || API Allociné Helper is support for using the API of Allociné : find lots of information about movies, people, etc.

PHP 100.00%

api-allocine-helper's Introduction

API Allociné Helper PHP

English version

L'API Allociné Helper permet d'utiliser plus simplement l'API d'AlloCiné. La classe AlloHelper permet de trouver des informations sur les films, stars, articles, horaires et critiques. Il est possible de manipuler les données reçues grâce à la classe AlloData (optionnel). La classe AlloImage permet de manipuler facilement la taille des posters et images stockés sur Allociné.

Installation

Déplacer le fichier api-allocine-helper.php dans le répertoire souhaité. Un simple require_once "./api-allocine-helper.php"; permet d'utiliser l'API dans votre code.

Usage

L'utilisation est très simple, néanmoins il est fortement conseillé de connaître la programmation orientée objet, et de savoir utiliser le bloc try{} catch(){}. Exemple d'utilisation pour récupérer les informations d'un film:

Premièrement, inclure le fichier et créer un objet AlloHelper:

<?php
    // Inclure le script
    require_once "./api-allocine-helper.php";
    
    // Créer l'objet
    $helper = new AlloHelper;
    

Pour plus de clareté, on définit les paramètres à l'avance: le code du film, et la quantité d'informations à récupérer.

    $code = 27061;
    $profile = 'small';
    

Ensuite, il est conseillé d'effectuer des requêtes dans un bloc try{} catch(){} pour gérer les erreurs.

    try
    {
        // Envoi de la requête
        $movie = $helper->movie( $code, $profile );
        
        // Afficher le titre
        echo "Titre du film: ", $movie->title, PHP_EOL;
        
        // Afficher toutes les données
        print_r($movie->getArray());
        
    }
    catch( ErrorException $error )
    {
        // En cas d'erreur
        echo "Erreur n°", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
    }
?>

English

API Allociné Helper is a support for using the API of AlloCiné. Find a lot of information about movies, people, tv series, etc, with the class AlloHelper. It is possible to manipulate the received data with the class AlloData (optional). And as a bonus, you can simply modify posters and photos from the Allociné server just by changing the URL with the class AlloImage.

Installation

This is just a script, you put it in your favorite directory and you do a require_once "./api-allocine-helper.php"; in your code.

Usage

Usage is very simple, however it is strongly advisable to know OOP, and the try{} catch(){} block.

First, create an AlloHelper object:

<?php
    // Include the script
    require_once "./api-allocine-helper.php";
    
    // Creat the object
    $helper = new AlloHelper;
    

For more clarity, we should define parameters before: the movie's code, and the quantity of information to get.

    $code = 27061;
    $profile = 'small';
    

Next, it's advisable to do requests in an try{} catch(){} block for handling errors.

    try
    {
        // Request sending
        $movie = $helper->movie( $code, $profile );
        
        // Print the title
        echo "Title: ", $movie->title, PHP_EOL;
        
        // Print all data
        print_r($movie->getArray());
        
    }
    catch( ErrorException $error )
    {
        // Error
        echo "Error ", $error->getCode(), ": ", $error->getMessage(), PHP_EOL;
    }
?>

api-allocine-helper's People

Contributors

etn406 avatar tuxboy avatar

Watchers

 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.