vinou/api-connector

3.2.0 2024-07-31 23:50 UTC

README

The Vinou API Connector is a PHP library that provides the stable functions and utilities that are enabled within the Vinou-Service-API and the Vinou-Public-API.

Table of contents

Installation

composer install vinou/api-connector

Usage Example

1. Basic instantiation

$api = new \Vinou\ApiConnector\Api (
        TOKEN_FOR_INSTANCE,
        AUTHID_FOR_VINOU_CUSTOMER	
      );

2. Instantiation with settings (recommended)

At first use constants to define path to config.yml

define(VINOU_CONFIG_DIR, '/Path/to/settings.yml');

The settings.yml looks like (Be careful keys are case sensitive)

vinou:
    token: TOKEN_FOR_INSTANCE
    authid: AUTHID_FOR_VINOU_CUSTOMER

than you can instantiate without piping the variables to the API-Object

$api = new \Vinou\ApiConnector\Api();

3. Improve session handling

By default the generated login token is stored to session. If you want to configure some additional api parameters or if you have some login issues it is better to instantiate a specific Vinou-Session before.

$session = new \Vinou\ApiConnector\Session\Session ();
$session::setValue('language','de');

This session handling is able to detect a TYPO3 session

4. Example function call

// returns all public wines of your Vinou-Office Account as php array
$api->getWinesAll()

5. Prepare Ajax connection (content of ajax.php e.g. called via https://your.domain.com/ajax.php)

<?php
        require_once __DIR__ . '/../vendor/autoload.php';

        define('VINOU_ROOT', realpath('./'));
        define('VINOU_MODE', 'Ajax');
        define('VINOU_CONFIG_DIR', '../config/');

        header('Cache-Control: no-cache, must-revalidate');
        header('Content-type: application/json');

        // INIT SESSION BEFORE ALL THE OTHER STUFF STARTS
        $session = new \Vinou\ApiConnector\Session\Session ();
        $session::setValue('language','de');

        $ajax = new \Vinou\ApiConnector\Ajax ();
        $ajax->run();
?>

Constants

Main options are set by constants. The following constants are avaiable.

Classlist

Provider

This Library is developed by the Vinou GmbH.

Vinou GmbH
Mombacher Straße 68
55122 Mainz
E-Mail: kontakt@vinou.de
Phone: +49 6131 6245390