New question

Question:

Date: 14-02-2020 06:26:11 (In Spanish)

Obtener token de mercado libre a través de la API[Unanswered]

Buenas, estoy intentando obtener el token de Mercado libre con el ejemplo de example_login.php y me devuelve
Login using MercadoLibre oAuth 2.0 y no logro obtener el token. Obviamente cargo mis id, key y estoy probando con SSL https

Alguien me puede dar una mano? Desde ya muchas gracias. Saludos

<?php
session_start();

require '../Meli/meli.php';
require '../configApp.php';

$meli = new Meli($appId, $secretKey);

if(isset($_GET['code']) || isset($_SESSION['access_token'])) {

// If code exist and session is empty
if(isset($_GET['code']) && !isset($_SESSION['access_token'])) {
// //If the code was in get parameter we authorize
try{
$user = $meli->authorize($_GET["code"], $redirectURI);

// Now we create the sessions with the authenticated user
$_SESSION['access_token'] = $user['body']->access_token;
$_SESSION['expires_in'] = time() + $user['body']->expires_in;
$_SESSION['refresh_token'] = $user['body']->refresh_token;
}catch(Exception $e){
echo "Exception: ", $e->getMessage(), "\n";
}
} else {
// We can check if the access token in invalid checking the time
if($_SESSION['expires_in'] < time()) {
try {
// Make the refresh proccess
$refresh = $meli->refreshAccessToken();

// Now we create the sessions with the new parameters
$_SESSION['access_token'] = $refresh['body']->access_token;
$_SESSION['expires_in'] = time() + $refresh['body']->expires_in;
$_SESSION['refresh_token'] = $refresh['body']->refresh_token;
} catch (Exception $e) {
echo "Exception: ", $e->getMessage(), "\n";
}
}
}

echo '<pre>';
print_r($_SESSION);
echo '</pre>';

} else {
echo '<a href="' . $meli->getAuthUrl($redirectURI, Meli::$AUTH_URL[$siteId]) . '">Login using MercadoLibre oAuth 2.0</a>';
}


Tags: PHP Votes: 0 - Answers: 0 - Views: 3 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

No replies for this question, be the first to answer.
To actively participate in the community first must authenticate, enter the system.Sign In