PHP code example of melibox / mercadolibre-php-sdk

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

    

melibox / mercadolibre-php-sdk example snippets




$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 change the $AUTH_URL value to match your user's Site Id.

$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)