/** * 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); } }
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 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 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 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 '../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>';
@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 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 {
} header("Location: api_example_login.php?action=login"); die; echo '<pre>'; print_r($_SESSION); echo '</pre>'; $token = $_SESSION['access_token']; $params = array('access_token' => $token); //$body = '{site_id:MLA}'; //$body = array('site_id'=>'MLA'); //$body = array('data' => '{"site_id":"MLA"}'); //$body = "site_id=MLA"; //$body = 'site_id=MLA'; $Result = $meli->post('/users/user_test', $body, $params); //$result = $meli->get('/users/219218138',$params); $result = $meli->get('/users/221958929', $params); //Test user //$result = $meli->get('/users/me',$params); $body = array("title" => "Item de testeo - No Ofertar", "category_id" => "MLA5529", "price" => 10, "currency_id" => "ARS", "available_quantity" => 1, "buying_mode" => "buy_it_now", "listing_type_id" => "bronze", "condition" => "new", "description" => "Item:, Ray-Man WAYFARER Gloss Black RB2140 901 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 months by Ray Ban", "pictures" => array(array("source" => "https://upload.wikimedia.org/wikipedia/commons/f/fd/Ray_Ban_Original_Wayfarer.jpg"), array("source" => "https://upload.wikimedia.org/wikipedia/commons/a/ab/Teashades.gif"))); $body = json_decode('{ "title":"Item de test - No Ofertar", "category_id":"MLA5529", "price":10, "currency_id":"ARS", "available_quantity":1, "buying_mode":"buy_it_now", "listing_type_id":"bronze", "condition":"new", "description": "Item:, Ray-Ban WAYFARER Gloss Black RB2140 901 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 months by Ray Ban",
<?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) {