Package to simplify the communication between the Mercado livre API and your app.
Package to simplify the integration between the Mercado livre API and your app., (*1)
composer require braghetto/hokoml
<?php $config = [ /** * Get app_id, secret_key and redirect_uri in te ML application manager (http://applications.mercadolibre.com/) */ 'app_id' => 'YOUR_APP_ID', 'secret_key' => 'YOUR_SECRET_KEY', 'redirect_uri' => 'YOUR_REDIRECT_URI', 'production' => false, /** * The ML code for your country * * MLA => Argentina * MBO => Bolivia * MLB => Brazil * MLC => Chile * MCO => Colombia * MCR => Costa Rica * MCU => Cuba * MRD => Dominican Republic * MEC => Ecuador * MGT => Guatemala * MHN => Honduras * MLM => Mexico * MNI => Nicaragua * MPA => Panama * MPY => Paraguay * MPE => Peru * MPT => Portugal * MSV => Salvador * MLU => Uruguay * MLV => Venezuela */ 'country' => 'YOUR_COUNTRY_CODE' ]
Retrive the auth to authorize your app., (*2)
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config); $url = $hokoml->getAuthUrl();
Once you have the code retrive the access token, user id, expiration and a refresh token., (*3)
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config); $response = $hokoml->authorize($_GET['code']); // Persist the data for future usage...
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config); // $refresh_token saved from your previous authorization $response = $hokoml->refreshAccessToken($refresh_token);
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']); $response = $hokoml->product()->create([ 'title' => 'TESTE RAY BAN', 'category_id' => 'MLB1227', 'price' => 900000, 'currency_id' => 'BRL', 'available_quantity' => 1, 'buying_mode' => 'buy_it_now', 'listing_type_id' => 'free', 'automatic_relist' => false, 'condition' => 'new', 'description' => 'Item:, <strong> Ray-Ban WAYFARER Gloss Black RB2140 901 </strong> Model: RB2140. Size: 50mm. Name: WAYFARER. Color: Gloss Black. Includes Ray-Ban Carrying Case and Cleaning Cloth. New in Box', 'warranty' => '12 month by Ray Ban', 'pictures' => [ ['source' => 'https://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg'], ['source' => 'https://upload.wikimedia.org/wikipedia/commons/a/ab/Teashades.gif'] ] ]);
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']); $response = $hokoml->product()->find($product_id);
Not all information can be update, so the packge will filter those info. Details here, (*4)
<?php // [...] $response = $hokoml->product()->update($product_id, [ 'title' => 'Milibin', 'price' => 800000, 'warranty' => 'New warranty', // Won't be updated // [...] ]);
<?php // [...] $response = $hokoml->product()->pause($product_id);
<?php // [...] $response = $hokoml->product()->unpause($product_id);
<?php // [...] $response = $hokoml->product()->finalize($product_id);
<?php // [...] $response = $hokoml->product()->relist($product_id, $price); // $response = $hokoml->product()->relist($product_id, $price, $quantity = 1, $listing_type = 'free');
<?php // [...] $response = $hokoml->product()->delete($product_id);
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']); // List all root categories $response = $hokoml->category()->list(); // List children categories for a given id. $response = $hokoml->category()->list($parent_category_id);
Predict a category for a given title., (*5)
<?php // [...] $response = $hokoml->category()->predict('Rayban Gloss Black');
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']); $response = $hokoml->question()->ask($question_id, 'The questions.');
<?php // [...] $response = $hokoml->question()->find($question_id);
<?php // [...] $response = $hokoml->question()->answer($question_id, 'The answer.');
List all questions from a product., (*6)
<?php // [...] $response = $hokoml->question()->fromProduct($product_id); // with filters $response = $hokoml->question()->fromProduct($product_id, [ 'status' => 'unanswered', [...] ]); // with filters and sorting $response = $hokoml->question()->fromProduct($product_id, ['status' => 'unanswered'], 'date_desc');
List all unanswered questions from a product., (*7)
<?php // [...] $response = $hokoml->question()->unansweredFromProduct($product_id);
<?php // [...] $response = $hokoml->question()->blockUser($user_id);
<?php // [...] $response = $hokoml->question()->unblockUser($user_id);
List blocked users., (*8)
<?php // [...] $response = $hokoml->question()->blockedUsers();
<?php // [...] $response = $hokoml->question()->received(); //With filters $response = $hokoml->question()->received([ 'status' => 'unanswered' ]); //With filters and sorting $response = $hokoml->question()->received(['status' => 'unanswered'], 'date_desc');
<?php use Braghetto\Hokoml\Hokoml; $hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']); $response = $hokoml->user()->me();
<?php [...] $response = $hokoml->user()->find($user_id);
Retrive the authenticated user addresses., (*9)
<?php [...] $response = $hokoml->user()->addresses();
Retrive payment methods accepted by the authenticated user., (*10)
<?php [...] $response = $hokoml->user()->acceptedPaymentMethods();
This project is licensed under the MIT License - see the license.md file for details, (*11)