Code Monkey home page Code Monkey logo

mercadolibre's Introduction

MercadoLibre PHP SDK

Latest version Software license Build status Coverage status Quality score

This package provides a PHP Software Development Kit (unofficial) for use with the MercadoLibre API, introducing some improvements to the official version, among which are the extension of the the MercadoLibre Provider for OAuth 2.0 Client, which in turn extends the OAuth 2.0 client library of the League of Extraordinary Packages, a group of developers who have banded together to build solid, well tested PHP packages using modern coding standards.

Install

Via Composer

$ composer require docta/mercadolibre

Documentation

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see LICENSE for more information.

mercadolibre's People

Contributors

lucascono avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

price2b

mercadolibre's Issues

Refresh Token

Bom dia!

Como utilizo o refresh token?

Cumprimentos

Docta/MercadoLibre para Laravel.

Trabajando con Laravel edite las variables utilizando INPUT and $request->session()->get. comenzo como un problema pero ahora con estos cambios funciona. quizas a alguien le sirva.

public function admin(Request $request)
{
    $authSite     = env('MELI_SDK_APP_SITE');
    $clientId     = env('MELI_SDK_APP_ID');
    $clientSecret = env('MELI_SDK_SECRET_ID');
    $redirectUri  = env('MELI_SDK_REDIRECT_URI');

    $client = new \Docta\MercadoLibre\Client($authSite, $clientId, $clientSecret, $redirectUri);

    /**
     * If we do not have an authorization code then get one
     */
    if (!$request->input('code')) {

        /**
         * Get the MercadoLibre authorization URL; return the url and also generate
         * and apply other necessary query parameters (for example: state).
         */
        $authUrl = $client->getAuthorizationUrl();

        /**
         * Get the generated state and save in session.
         */
        $request->session()->put('state',$client->getState());

        /**
         * Redirect the user to the authorization URL
         */
        header('Location: '.$authUrl);
        exit;

        /**
         * Check the state returned by MercadoLibre against the state
         * previously stored in session to mitigate the CSRF attack.
         */
    }
    elseif (empty($request->input('state') || ($request->input('state') !== $request->session()->get('state')))) {

        !$request->session()->get('state');
        exit('Invalid state');

        /**
         * If the state stored in session and the state returned
         * by MercadoLibre are the same, then continue.
         */
    }
    else {

        try {
            /**
             * Try to exchange the code obtained by an access
             * token (using the authorization code grant).
             */
            $client->setToken($request->input('code'));

            /**
             * Optional: Now that we have a token, we can check
             * the data of the owner of the resources.
             */
            $owner = $client->getOwner();
            /**
             * And from now on to be able to consult the protected resources.
             * The following example makes the same request as the `getOwner()` method.
             */
            $me = $client->get('/users/me');

            /**
             * Failed to get the access token, the owner details or the items request.
             */
        } catch (\Docta\MercadoLibre\Exception\ClientException $e) {

            exit($e->getMessage());

        }
    }
}

Tempo access token

Boa tarde!

Quantas horas dura o access token?
Como poderei atualiza-lo ou verificar se foi expirado?

Cumprimentos.

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.