<?php if ($_GET['action'] == "login") { session_name('testml'); session_start(); require '../../classes/class.meli.php'; $Meli = new Meli('4853777712698373', 'zhBim3Li6QKCTUht49YLnhpbT66CQwGm', $_SESSION['access_token'], $_SESSION['refresh_token']); $URL = 'http://localhost/projects/admin/files/modules/test/test.php'; if (!$_SESSION['code']) { header("Location: " . $Meli->getAuthUrl($URL, Meli::$AUTH_URL['MLA'])); die; } if ($_GET['code'] && !$_SESSION['code']) { $_SESSION['code'] = $_GET['code']; } // If code exist and session is empty if ($_SESSION['code'] && !$_SESSION['access_token']) { // If the code was in get parameter we authorize $user = $Meli->authorize($_SESSION['code'], $URL); // 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; } header("Location: api_example.php"); die; } ?> <!DOCTYPE html> <html> <head>
<?php session_start(); require '../MercadoLivre/meli.php'; $meli = new Meli('APP_ID', 'SECRET_KEY'); if ($_GET['code']) { // If the code was in get parameter we authorize $user = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); // Now we create the sessions with the authenticated user $_SESSION['access_token'] = $user['body']->access_token; $_SESSION['expires_in'] = $user['body']->expires_in; $_SESSION['refrsh_token'] = $user['body']->refresh_token; // We can check if the access token in invalid checking the time if ($_SESSION['expires_in'] + time() + 1 < time()) { try { print_r($meli->refreshAccessToken()); } catch (Exception $e) { echo "Exception: ", $e->getMessage(), "\n"; } } // We construct the item to POST $item = array("title" => "Rayban Gloss Black", "subtitle" => "Some subtitle here", "category_id" => "MLB1227", "price" => 10, "currency_id" => "BRL", "available_quantity" => 1, "buying_mode" => "buy_it_now", "listing_type_id" => "bronze", "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", "video_id" => "RXWn6kftTHY", "warranty" => "12 month by Ray Ban", "pictures" => array(array("source" => "http://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"), array("source" => "http://en.wikipedia.org/wiki/File:Teashades.gif"))); // We call the post request to list a item echo '<pre>'; print_r($meli->post('/items', $item, array('access_token' => $_SESSION['access_token']))); echo '</pre>'; } else { echo '<a href="' . $meli->getAuthUrl('http://localhost/PHPSDK/examples/example_login.php') . '">Login using MercadoLibre oAuth 2.0</a>'; }
public function show($id) { if (!session('profile')) { return \Redirect::to('/meli/login'); } /*$product = \Meli::get('/myfeeds', [ 'access_token' => session('access_token'), 'app_id' => env('ML_APP_ID') ]);dd($product)*/ /*dd(\Meli::get('/items/'. $id, [ 'access_token' => session('access_token'), 'seller' => session('profile')->id, 'order' => 'asc' ])); dd($product);*/ $product = \Meli::get('/items/' . $id, ['access_token' => session('access_token')]); //echo '<pre>'; //var_dump($product['body']);die; $this->_result = $product['body']; //dd($this->_result); // echo '<pre>'; // var_dump($this->_result->shipping); // echo '</pre>'; //dd($this->_result); return view('mercadolibre::admin.product.details')->with('product', $this->_result); }
/** * Get Acces Token Page */ public function callback(Request $request) { $error = $request->input('error'); $error_description = $request->input('error_description'); $code = $request->input('code'); $access_token = session('access_token'); if ($error) { return view('mercadolibre::login')->with('auth', ['error' => $error, 'description' => $error_description, 'url' => \Meli::getAuthUrl(env('ML_AUTHENTICATION_URL', ''))]); } if ($code || $access_token) { if ($code && !$access_token) { $user = \Meli::authorize($code, env('ML_AUTHENTICATION_URL')); session(['access_token' => $user['body']->access_token]); session(['expires_in' => time() + $user['body']->expires_in]); session(['refresh_token' => $user['body']->refresh_token]); $me = \Meli::get('/users/me', ['access_token' => session('access_token')]); session(['profile' => $me['body']]); } else { if (session('expires_in') < time()) { try { $refresh = \Meli::refreshAccessToken(session('refresh_token')); 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() . PHP_EOL; } } } return \Redirect::to('/meli/admin'); } else { $auth_url = \Meli::getAuthUrl(env('ML_AUTHENTICATION_URL', '')); return view('mercadolibre::login')->with('auth_url', $auth_url); } }
/** * get Topic Data */ private function getTopic() { $token = \Meli::getTokenByConsole(); $topic = \Meli::get($this->topics->resource, ['access_token' => $token['access_token']]); //var_dump($topic);die; if (isset($topic['body']) && isset($topic['httpCode']) && $topic['httpCode'] == 200) { return $topic['body']; } return false; }
public function show($id) { if (!session('profile')) { return \Redirect::to('/meli/login'); } $product = \Meli::options('/items/' . $id, ['access_token' => session('access_token')]); $this->_result = $product['body']; //echo '<pre>'; //var_dump($this->_result);die; return view('mercadolibre::admin.questions.details')->with('product', $this->_result); }
public function getRecentOrders() { if (!session('profile')) { return \Redirect::to('/meli/login'); } $orders = \Meli::get('/orders/search/recent', ['access_token' => session('access_token'), 'seller' => session('profile')->id, 'sort' => 'date_desc', 'limit' => 50]); $orderList = []; if (isset($orders['body']->results) && !empty($orders['body'])) { foreach ($orders['body']->results as $order) { $orderList[] = array('<a href="' . url("/meli/admin/order", ["id" => $order->id]) . '" target="_blank">' . $order->id . '</a>', $order->status, $order->buyer->first_name . ' ' . $order->buyer->last_name, $order->buyer->email, $order->buyer->phone->number, '$ ' . number_format($order->total_amount, 2), date('Y-m-d', strtotime($order->date_created))); $this->_result = $orderList; } } $this->_result = $orderList; return response()->json(['data' => $this->_result]); }
public function show($id) { if (!session('profile')) { return \Redirect::to('/meli/login'); } $store = \Meli::get('/users/' . session('profile')->id . '/brands/' . $id, []); $categories = []; if (isset($store['body']->categories_ids) && !empty($store['body']->categories_ids)) { foreach ($store['body']->categories_ids as $category) { $childrens = []; $_category = \Meli::get('/categories/' . $category, []); if (isset($_category['body']->children_categories) && !empty($_category['body']->children_categories)) { foreach ($_category['body']->children_categories as $children) { $childrens[] = ['id' => $children->id, 'name' => $children->name, 'total_items' => $children->total_items_in_this_category]; } } $categories[] = ['id' => $_category['body']->id, 'name' => $_category['body']->name, 'picture' => $_category['body']->picture, 'permalink' => $_category['body']->permalink, 'total_items_in_this_category' => $_category['body']->total_items_in_this_category, 'children_categories' => $childrens]; } } $this->_result = ['_store' => $store['body'], '_categories' => $categories]; //echo '<pre>'; //var_dump($this->_result);die; return view('mercadolibre::admin.stores.details')->with('data', $this->_result); }
<?php session_name('testml'); session_start(); // session_destroy(); // die(); require '../../classes/class.meli.php'; require '../../classes/class.database.php'; $DB = new DataBase(); $DB->Connect(); $URL = 'https://renovatio-cheketo.c9users.io/files/modules/test/landing.php'; //$CallBack = 'https://renovatio-cheketo.c9users.io/files/modules/test/landing.php'; $Meli = new Meli('1204162705833882', '9BSgeYbRpo4PCAOaCqYzhEqPo7354DyY', $_SESSION['access_token'], $_SESSION['refresh_token']); $UserData = $DB->fetchAssoc("admin_user", "*", "admin_id=8"); $_SESSION['code'] = $UserData[0]['code']; $_SESSION['access_token'] = $UserData[0]['access_token']; $_SESSION['refresh_token'] = $UserData[0]['refresh_token']; $_SESSION['expires_in'] = $UserData[0]['expires_in']; if (!$_SESSION['code']) { header("Location: " . $Meli->getAuthUrl($URL, Meli::$AUTH_URL['MLA'])); die; } else { if (!$_SESSION['access_token']) { // If the code was in get parameter we authorize $UserML = $Meli->authorize($_SESSION['code'], $URL); // Now we create the sessions with the authenticated user $_SESSION['access_token'] = $UserML['body']->access_token; $_SESSION['expires_in'] = time() + $UserML['body']->expires_in; $_SESSION['refresh_token'] = $UserML['body']->refresh_token; $DB->execQuery("UPDATE", "admin_user", "access_token='" . $_SESSION['access_token'] . "', refresh_token='" . $_SESSION['refresh_token'] . "', expires_in=" . $_SESSION['expires_in'], "admin_id=8"); //echo "AT".$DB->lastQuery();
<?php require '../MercadoLivre/meli.php'; $meli = new Meli('APP_ID', 'SECRET_KEY'); $params = array(); $result = $meli->get('/sites/MLB', $params); echo '<pre>'; print_r($result); echo '</pre>';
<?php session_start('teste'); require '../MercadoLivre/meli.php'; $meli = new Meli('APP_ID', 'SECRET_KEY', $_SESSION['access_token'], $_SESSION['refresh_token']); if ($_GET['code'] || $_SESSION['access_token']) { // If code exist and session is empty if ($_GET['code'] && !$_SESSION['access_token']) { // If the code was in get parameter we authorize $user = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); // 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; } 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);
// Mercado Libre test user // { // "id": 221958929, // "nickname": "TETE2556564", // "password": "******", // "site_status": "active", // "email": "*****@*****.**" // } // MercadoLibre Test File - Just to test ML API session_name('testml'); session_start(); //session_destroy();print_r($_SESSION);die(); require '../../classes/class.meli.php'; $URL = 'http://localhost/projects/admin/files/modules/test/test.php'; $meli = new Meli('4853777712698373', 'zhBim3Li6QKCTUht49YLnhpbT66CQwGm', $_SESSION['access_token'], $_SESSION['refresh_token']); if ($_GET['code'] && !$_SESSION['code']) { $_SESSION['code'] = $_GET['code']; } if ($_SESSION['code'] || $_SESSION['access_token']) { // If code exist and session is empty if ($_SESSION['code'] && !$_SESSION['access_token']) { // If the code was in get parameter we authorize $user = $meli->authorize($_SESSION['code'], $URL); // 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; } else { // We can check if the access token in invalid checking the time if ($_SESSION['expires_in'] < time()) {
<?php require '../src/meli.php'; // Create our Application instance (replace this with your appId and secret). $meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret')); $userId = $meli->initConnect(); // Login or logout url will be needed depending on current user state. if ($userId) { $user = $meli->getWithAccessToken('/users/me'); } ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>MeliPHP SDK - Example login</title> </head> <body> <h1>MeliPHP SDK - Example login</h1> <?php if ($userId) { ?> <p>Hello <?php echo $user['json']['first_name']; ?> </p> <a href="<?php echo $meli->getLogoutUrl(); ?>
<?php require '../../../MercadoLivre/meli.php'; $meli = new Meli(6977659590438028, "Bod7085COHJXx00mXd09kWMoHWr6cDLD"); if ($_GET['code']) { $oAuth = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); $_SESSION['access_token'] = $oAuth['body']->access_token; } else { echo '<a href="' . $meli->getAuthUrl('http://CALLBACK_URL') . '">Login with MercadoLibre</a>'; } //session_start(); //require '../../MercadoLivre/meli.php'; //$meli = new Meli('7591845110154875', 'QiDwHZjfJcPdVg9hYzXWv1gbneq9piY9', $_SESSION['access_token'], $_SESSION['refresh_token']); //if($_GET['code'] || $_SESSION['access_token']) { // // // If code exist and session is empty // if($_GET['code'] && !($_SESSION['access_token'])) { // // If the code was in get parameter we authorize // $user = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); // // // 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; // } // // if($_GET['code'] && !($_SESSION['access_token'])) { // // If the code was in get parameter we authorize // $user = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); // // // Now we create the sessions with the authenticated user
@section('description') @stop @section('style') @stop @section('breadcrumb') @stop @section('content') <?php require '../app/phpsdkmaster/MercadoLivre/meli.php'; $meli = new Meli('5909368031571237', 'tqOqeQIli8gvYOHZ2BIgSjCx7Bp0xU9z'); //$meli = new Meli('5909368031571237', 'tqOqeQIli8gvYOHZ2BIgSjCx7Bp0xU9z', $_SESSION['access_token'], $_SESSION['refresh_token']); // Create our Application instance (replace this with your appId and secret). if ($_GET['code']) { $oAuth = $meli->authorize($_GET['code'], 'http://miproteina.contapp.com.co/login'); $_SESSION['access_token'] = $oAuth['body']->access_token; } else { echo 'Login with MercadoLibre'; } $item = $meli->get("/users/70590888/items/search", array('access_token' => $_SESSION['access_token'])); ?> <pre>hola creo que estoy logeado y tengo <?php print_r($item); ?> </pre> @stop
<?php // Token validation from Mercado Libre session_name('testml'); session_start(); require '../../classes/class.meli.php'; $URL = 'http://localhost/projects/admin/files/modules/test/validate_token.php'; $meli = new Meli('4853777712698373', 'zhBim3Li6QKCTUht49YLnhpbT66CQwGm', $_SESSION['access_token'], $_SESSION['refresh_token']); if ($_SESSION['code'] || $_SESSION['access_token']) { // If code exist and session is empty if ($_SESSION['code'] && !$_SESSION['access_token']) { // If the code was in get parameter we authorize $user = $meli->authorize($_SESSION['code'], $URL); // 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; echo $_SESSION['access_token']; } 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; echo $_SESSION['access_token']; } catch (Exception $e) { echo "Exception: ", $e->getMessage(), "\n";
<?php require '../src/meli.php'; // Create our Application instance (replace this with your appId and secret). $meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret')); $userId = $meli->initConnect(); // Login or logout url will be needed depending on current user state. if ($userId) { if (isset($_REQUEST['question_id']) == 1) { $response = $meli->postWithAccessToken('/answers', array('question_id' => $_REQUEST['question_id'], 'text' => $_REQUEST['answer_text'])); $_SESSION['answer_question'] = true; header("Location: " . $meli->getCurrentUrl(), TRUE, 302); } $user = $meli->getWithAccessToken('/users/me'); $unansweredQuestions = $meli->getWithAccessToken('/questions/search', array('seller' => $user['json']['id'], 'status' => 'UNANSWERED')); } ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>MeliPHP SDK - Example questions</title> </head> <body> <h1>MeliPHP SDK - Example questions</h1> <?php if ($userId) { ?> <p>Hello <?php echo $user['json']['first_name'];
<?php session_start('teste'); require '../MercadoLivre/meli.php'; $meli = new Meli('APP_ID', 'SECRET_KEY'); if ($_GET['code']) { // If the code was in get parameter we authorize $user = $meli->authorize($_GET['code'], 'http://localhost/PHPSDK/examples/example_login.php'); // Now we create the sessions with the authenticated user $_SESSION['access_token'] = $user['body']->access_token; $_SESSION['expires_in'] = $user['body']->expires_in; $_SESSION['refrsh_token'] = $user['body']->refresh_token; // We can check if the access token in invalid checking the time if ($_SESSION['expires_in'] + time() + 1 < time()) { try { print_r($meli->refreshAccessToken()); } catch (Exception $e) { echo "Exception: ", $e->getMessage(), "\n"; } } $params = array('access_token' => $_SESSION['access_token']); $body = array('text' => 'Adding new description <strong>html</strong>'); $response = $meli->put('/items/MLB12343412/descriptions', $body, $params); } else { echo '<a href="' . $meli->getAuthUrl('http://localhost/PHPSDK/examples/example_login.php') . '">Login using MercadoLibre oAuth 2.0</a>'; }
<?php require '../src/meli.php'; // Create our Application instance (replace this with your appId and secret). $meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret')); $PMSToolId = 'PMSToolId'; $paging = ""; if (isset($_REQUEST['offset'])) { $paging = $_REQUEST['offset']; } if (isset($_REQUEST['q'])) { $query = $_REQUEST['q']; $search = $meli->get('/sites/#{siteId}/search', array('q' => $query, 'offset' => $paging)); $search = $search['json']; $currenciesJSON = $meli->get('/currencies'); $currenciesJSON = $currenciesJSON["json"]; $currencies = array(); foreach ($currenciesJSON as &$currency) { $currencies[$currency["id"]] = $currency; } } function add_or_change_parameter($parameter, $value) { $params = array(); $output = "?"; $firstRun = true; foreach ($_GET as $key => $val) { if ($key != $parameter) { if (!$firstRun) { $output .= "&"; } else {
<?php require '../dBug.php'; require '../src/meli.php'; $meli = new Meli(array('appId' => '5804', 'secret' => '')); $userId = $meli->initConnect(); if ($userId) { $pauseAction = array('status' => 'paused'); if (isset($_REQUEST['item_id']) == 1) { $response = $meli->putWithAccessToken('/items/' . $_REQUEST['item_id'], $pauseAction); } $session_content = $meli->getAccessToken(); } ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>Meli PHP SDK</title> </head> <body> <?php if ($userId) { ?> <h1>Meli-PHP Pause Test - <strong style="color: #009900">[Logged in]</strong></h1> <div> <form method="POST"> <fieldset> <label for="item_id">Item ID</label> <input type="text" name="item_id" id="item_id" size="20"> <input type="submit" value="Enviar">
$MeliURL = 'https://renovatio-cheketo.c9users.io/files/modules/test/landing.php'; /* MELI NOTIFICATIONS URL */ $MeliNotificationsURL = 'https://renovatio-cheketo.c9users.io/files/modules/test/notifications.php'; /* SECURIRTY CHECKS */ $Security = new Security(); if ($Security->checkProfile($_SESSION['admin_id'])) { $Admin = new AdminData(); $Cookies = new Login($Admin->User); $Cookies->setCookies(); if (!$Security->checkCustomer($_SESSION['company_id'])) { header("Location: ../login/process.logout.php?error=customer"); die; } // MELI SESSION if ($_SESSION['meli']) { $Meli = new Meli($_SESSION['meli_application_id'], $_SESSION['meli_secret'], $_SESSION['meli_access_token'], $_SESSION['meli_refresh_token']); if ($_SESSION['meli_refresh_token']) { $Meli->refreshMeliToken(); } } } /* ADDING SLASHES TO PUBLIC VARIABLES */ $_POST = AddSlashesArray($_POST); $_GET = AddSlashesArray($_GET); /* SETTING HEAD OF THE DOCUMENT */ $Head = new Head(); $Head->setFavicon("../../../skin/images/body/icons/favicon.png"); /* SETTING FOOT OF THE DOCUMENT */ $Foot = new Foot(); /* SETTING MENU OF THE DOCUMENT */ $Menu = new Menu();
<?php include '../../includes/inc.main.php'; if ($_GET['sync'] == 'no') { $_SESSION['meli'] = false; unset($_SESSION['meli_code']); unset($_SESSION['meli_access_token']); unset($_SESSION['meli_refresh_token']); unset($_SESSION['meli_expires_in']); $DB->execQuery("UPDATE", "admin_user", "meli=0,meli_access_token='',meli_refresh_token='', meli_code='',meli_expires_in='0'", "admin_id=" . $_SESSION['admin_id']); header("Location: ../main/main.php"); } else { /// MELI LOGIN $_SESSION['meli'] = true; $Meli = new Meli($_SESSION['meli_application_id'], $_SESSION['meli_secret']); header("Location: " . $Meli->getAuthUrl($MeliURL, Meli::$AUTH_URL['MLA'])); } die;
<?php require '../src/meli.php'; // Create our Application instance (replace this with your appId and secret). $meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret')); if (isset($_REQUEST['item_id']) && $_REQUEST['item_id'] != null) { $itemId = $_REQUEST['item_id']; $item = $meli->get('/items/' . $itemId); } ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>MeliPHP SDK - Example Item</title> </head> <body> <h1>MeliPHP SDK - Example Item</h1> <form> <input name="item_id" value="<?php echo isset($item['json']) ? $itemId : ''; ?> " /> <input type="submit" name="show item" value="show item"/> </form> <?php if (isset($item['json'])) { ?> <p><?php
<?php require '../src/meli.php'; // Create our Application instance (replace this with your appId and secret). $meli = new Meli(array('appId' => 'MeliPHPAppId', 'secret' => 'MeliPHPSecret')); if (isset($_REQUEST['q'])) { $query = $_REQUEST['q']; $search = $meli->get('/sites/#{siteId}/search', array('q' => $query)); } ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>MeliPHP SDK - Example Search</title> </head> <body> <h1>MeliPHP SDK - Example Search</h1> <form> <input name="q" value="<?php echo $query; ?> " /> <input type="submit" name="search" value="search"/> </form> <ol> <?php foreach ($search['json']['results'] as &$searchItem) {