1. Go to this page and download the library: Download braghetto/hokoml library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
braghetto / hokoml example snippets
$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'
]
use Braghetto\Hokoml\Hokoml;
$hokoml = new Hokoml($config);
$url = $hokoml->getAuthUrl();
use Braghetto\Hokoml\Hokoml;
$hokoml = new Hokoml($config);
$response = $hokoml->authorize($_GET['code']);
// Persist the data for future usage...
use Braghetto\Hokoml\Hokoml;
$hokoml = new Hokoml($config);
// $refresh_token saved from your previous authorization
$response = $hokoml->refreshAccessToken($refresh_token);
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']
]
]);
use Braghetto\Hokoml\Hokoml;
$hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']);
$response = $hokoml->product()->find($product_id);
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);
use Braghetto\Hokoml\Hokoml;
$hokoml = new Hokoml($config, $_SESSION['access_token'], $_SESSION['user_id']);
$response = $hokoml->question()->ask($question_id, 'The questions.');