Download the PHP package waltersilvacruz/laravel-meli without Composer
On this page you can find all versions of the php package waltersilvacruz/laravel-meli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download waltersilvacruz/laravel-meli
More information about waltersilvacruz/laravel-meli
Files in waltersilvacruz/laravel-meli
Package laravel-meli
Short Description A Laravel wrapper for Mercado Livre Rest API
License MIT
Informations about the package laravel-meli
MercadoLibre API Integration for Laravel
Integrate your Laravel Application with MercadoLibre's API.
Based on vcoud/mercadolibre (thank you, man!).
PHP client wrapper for MercadoLibre API.
This package was designed to work with Laravel, so it was written with Laravel in mind.
Installation
-
Install with composer:
- Run the migration command to create the
meli_app_tokens
table:
The package uses the auto registration feature of Laravel.
Configuration
IMPORTANT: Before you start, check the following:
- You must have a MercadoLibre account
- You must create an APP into ML's DevSite
- The APP must have the
offline_access
scope enabled (otherwise the refresh token will not be generated) - You must have both APP Code and Client Secret in hands to setup into your Laravel application.
-
Add the appropriate values to your
example:
-
Publish configs & views [optional]
Config file
A configuration file named can be published to by running the following command:
Publishing Views
View files can also be published by using:
The blade's templates will be published into
resources/views/vendor/meli
folder, so you can customize the templates to apply your application's look and feel. - Clear your route and config caches:
Usage
First, connect your Laravel Application into MercadoLibre via Oauth
You can connect to ML opening this link on browser:
<your-app-site>/meli/connect/<state>
. Here, the <state>
parameter is mandatory!
This wrapper uses <state>
as unique identifier for each authentication token, allowing your site to connect to multiples ML accounts.
Example:
Using methods to retrieve data from ML
Once connected, you can perform queries to ML's API using one of the following methods:
Sample code:
Every call returns an stdClass
object:
Please refer to ML API docs to learn about all available endpoints and its response data.
Multiples Connections
Yes, we can! It is possible to connect to multiples ML accounts at same time.
Let's imagine the following scenario:
- Your app has multiple users.
- Each user can connect to their ML account.
- Each user must access only his own ML data.
Make sure each user will have a UNIQUE state identification.
Each user will be prompted to log in via ML OAuth, then they must allow your application to connect into their accounts. The auth and refresh tokens for each state will be stored into meli_app_tokens
table. The state
column will be the key to fetch the correct token when instantiate the service.
Command line utility
This package comes with a utility command to help you create test users on MercadoLibre.
You can use one of the following options for the [site] parameter:
Example:
Automatic token refreshing
The auth token last for 6 hours after its creation. After this, the auth token expires and a new one will be automatically generated using the refresh token before sending you query.
The auth token refreshing is automatic and no user action is required.
In other hand, the refresh token will expire after 6 months and the user MUST log in again to grab a fresh new one.
Documentation & Important notes
The URIs are relative to https://api.mercadolibre.com
Don’t forget to check out the MercadoLibre developer site
Official Laravel documentation
All versions of laravel-meli with dependencies
ext-curl Version *
ext-json Version *