Pregunta:
Fecha: 14-02-2020 06:26:11
(En Español)
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>';
}
Votos: 0 - Respuestas: 2 - Vistas: 8 Compartir en: Google Facebook Twitter LinkedIn Link
Obtener token de mercado libre a través de la API[No resuelta]
Buenas, estoy intentando obtener el token de Mercado libre con el ejemplo de example_login.php y me devuelveLogin 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>';
}
Votos: 0 - Respuestas: 2 - Vistas: 8 Compartir en: Google Facebook Twitter LinkedIn Link
Respuestas:
-
Fecha: 14-04-2020 19:31:55 Hola Guillermo pudo resolverlo? Yo las. Prueba que hice con mercadolibre las realicé con php y Curl. Votos: 0 - Link respuesta
-
Fecha: 15-04-2020 07:42:06 Muchas gracias Sebastián por tu respuesta. Me podrás enviar tu código que funciona para usar de ejemplo? Saludos Votos: 0 - Link respuesta
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión