Coder Social home page Coder Social logo

hiboutikapi's Introduction

PHP library for Hiboutik API

This repository contains the open source PHP library that allows you to access the Hiboutik Platform from your PHP app.

Requirements

  • PHP 5.3.0 or newer
  • PHP cURL extension

Installation

Composer

The Hiboutik PHP library can be installed with Composer. Run this command:

composer require hiboutik/hiboutikapi

And in your script

<?php
require 'vendor/autoload.php';

Manual installation

Download this package and include the autoloader.

<?php

require 'HiboutikAPI/src/Hiboutik/autoloader.php';

Quick Documentation

There are two types of authentication available: basic and OAuth.

Basic authentication

$hiboutik = new \Hiboutik\HiboutikAPI(YOUR_HIBOUTIK_ACCOUNT, USER, KEY);

OAuth

$hiboutik = new \Hiboutik\HiboutikAPI(YOUR_HIBOUTIK_ACCOUNT);
$hiboutik->oauth(ACCESS_TOKEN);

Usage

To list all active products on your account:

$result = $hiboutik->get("/products/");
if ($hiboutik->request_ok) {
  print_r($result);
} else {
  if (isset($result['details']['error_description'])) {
    print $result['details']['error_description'];
  } else {
    print $result['error_description'];
  }
}

To create a new product:

$result = $hiboutik->post("products", [
  "product_model" => "My product",
  "product_barcode" => "",
  "product_brand" => "2",
  "product_supplier" => "2",
  "product_price" => "99.90",
  "product_discount_price" => "89.90",
  "product_category" => 5,
  "product_size_type" => 0,
  "product_stock_management" => 0,
  "product_supplier_reference" => "",
  "product_vat" => 0
]);

if ($hiboutik->request_ok) {
  print 'Product created!';
} else {
  if (isset($result['details']['error_description'])) {
    print $result['details']['error_description'];
  } else {
    print $result['error_description'];
  }
}

Pagination

The large datasets are paginated in the Hiboutik's API. Get the pagination information:

$pagination = $hiboutik->pagination();

Legacy support

For the scripts using the previous version of this package the old methods are still available. The only difference is in the addition of a parameter in the constructor. The API version must be specified for the v1:

$hiboutik = new \Hiboutik\HiboutikAPI(YOUR_HIBOUTIK_ACCOUNT, USER, KEY, '1');

hiboutikapi's People

Contributors

hiboutik avatar hiboutik2 avatar

Watchers

James Cloos 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.