PHP code example of somosyampi / mercadolibre

1. Go to this page and download the library: Download somosyampi/mercadolibre 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/ */

    

somosyampi / mercadolibre example snippets


use Vcoud\Mercadolibre\Meli;

$meli = new Meli('1234', 'a secret');

$meli = new Meli('1234', 'a secret', 'Access_Token', 'Refresh_Token');

$redirectUrl = $meli->getAuthUrl("http://somecallbackurl",Meli::$AUTH_URL['MLB']); //  Don't forget to set the autentication URL of your country.

$user = $meli->authorize($_GET['code'], 'http://somecallbackurl');

$params = array('access_token' => $access_token);
$result = $meli->get('/users/me', $params); 
 #If you wish , you can get an associative array with param $assoc = true Example:
$result = $meli->get('/users/me', $params, true); 

$params = array('access_token' => $access_token);

  #this body will be converted into json for you
$body = array('foo' => 'bar', 'bar' => 'foo');

$response = $meli->post('/items', $body, $params);

$params = array('access_token' => $access_token);

  #this body will be converted into json for you
$body = array('foo' => 'bar', 'bar' => 'foo');

$response = $meli->put('/items', $body, $params);

$params = array('access_token' => $access_token);
$response = $meli->delete('/questions/123', $params)