Giter Club home page Giter Club logo

allegro-api's Introduction

README

The PHP interface which allows you to communicate with Allegro WebAPI and RestApi

Requirements

  • PHP >= 5.2.4

Installation

Composer (recommended)

$ composer require asocial-media/allegro-api

Manually

$ git clone https://github.com/asocial-media/allegro-api.git

or just download zip archive

Basic usage of Allegro RestApi

// Used namespace
use AsocialMedia\AllegroApi\AllegroRestApi;

// Register your application here:
// https://apps.developer.allegro.pl

// Creating auth URL using client id and redirect_uri
var_dump(
    AllegroRestApi::getAuthLink($clientId, $redirectUri)
);

// After clicking above link you need to grant permission and then
// you will be redirected to:
//     $redirectUri with special code in URL (GET)
//
// Use above code to finally generate your access token
$tokens = AllegroRestApi::generateToken(
    (isset($_GET['code']) ? $_GET['code'] : null), 
    $clientId, 
    $clientSecret, 
    $redirectUri
);

// Token will be active for 12 hours and you can refresh 
// it indefinitely (via cron job)
AllegroRestApi::refreshToken(
    $tokens->refresh_token, 
    $clientId, 
    $clientSecret, 
    $redirectUri
);

// If we have our access token we can finally request REST API

// Creating an instance of RestApi
$restApi = new AllegroRestApi($tokens->access_token);

// Getting our comments
$response = $restApi->get('/sale/user-ratings?user.id=' . $yourUserId);

// Creating 2 variants using color/pattern
$response = $restApi->put('/sale/offer-variants/' . $restApi->getUuid(), array(
    'name'       => 'Wariant 1',
    'offers'     => array(
        array(
            'id'           => '6846772956',
            'colorPattern' => 'yellow_gold'
        ),
        array(
            'id'           => '6846772915',
            'colorPattern' => 'white_rhodium'
        )
    ),
    'parameters' => array(
        array(
            'id' => 'color/pattern'
        ),
    )
), array(
    'Content-Type' => 'application/vnd.allegro.beta.v1+json', // Some actions needs version change from "public" to "beta"
    'Accept'       => 'application/vnd.allegro.beta.v1+json', // Some actions needs version change from "public" to "beta"
));

Basic usage of Allegro WebApi

// Used namespace
use AsocialMedia\AllegroApi\AllegroApi;

// Creating new instance of AllegroApi
$api = new AllegroApi('your_api_key');

// We are going to login using Allegro WebApi
$api->login(array(
    'userLogin'    => 'example',
    'userPassword' => 'examplepass',
    'countryCode'  => $api->getCountry(),
    'webapiKey'    => $api->getApiKey(),
    'localVersion' => $api->getVersionKey(),
));
// For now, we have an access to $api->getSession()

// Getting our current black list using Allegro WebApi
$response = $api->doGetBlackListUsers(array(
    'sessionHandle' => $api->getSession(),
));

// We can also omit "do" prefix in method names
$response = $api->getBlackListUsers(array(
    'sessionHandle' => $api->getSession(),
));

Authors

License

The files in this archive are released under the MIT LICENSE.

allegro-api's People

Contributors

jchaos avatar mstraczkowski avatar vt-parhomenko 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.