Skip to content

Instantly share code, notes, and snippets.

@ivandez
Created November 24, 2021 02:38
Show Gist options
  • Save ivandez/957d27a7dc70b9fb0943139f2f64d59c to your computer and use it in GitHub Desktop.
Save ivandez/957d27a7dc70b9fb0943139f2f64d59c to your computer and use it in GitHub Desktop.
token de amazon
<?php
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
Route::get('get-token', function () {
$url = 'https://servicios.api.seur.io/pic_token';
$data = [
'grant_type' => 'password',
'client_id' => '349f9047',
'client_secret' => '55f7fa50244ad35c319b1f387ae83966',
'username' => 'maya_pro',
'password' => 'Seur1234$'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$result = curl_exec($ch);
curl_close($ch);
return ($result);
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@yield('title')</title>
<meta name="description" content="Verificación de datos de pagos de amazon." />
<meta name="keywords" content="" />
<link rel="canonical" href="#" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" href="{{ asset('media/logos/favicon.ico') }}" />
<meta name="csrf-token" content="SdCuQfDyxbuG9jNymNvzaC9B1IFOPBhCDrpLKcoP">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700" />
<link href="{{ asset('plugins/global/plugins.bundle.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/style.bundle.css') }}" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk="
crossorigin="anonymous"></script>
<link href="{{ asset('plugins/custom/datatables/datatables.bundle.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('plugins/custom/prismjs/prismjs.bundle.css') }}" rel="stylesheet" type="text/css" />
</head>
<body id="kt_body" style="background-image: url('{{ asset('media/palmas.jpg') }}');"
class="header-fixed header-tablet-and-mobile-fixed toolbar-enabled toolbar-fixed toolbar-tablet-and-mobile-fixed aside-enabled aside-fixed"
style="--kt-toolbar-height:55px;--kt-toolbar-height-tablet-and-mobile:55px">
<div class="container h-100">
<div class="row h-100 justify-content-center align-items-center">
<div class="col" style="max-width:50%;">
<div style="text-align: center;
display: block;">
<img src="{{ asset('media/maia_logo.png') }}" style="max-width:200px;">
</div>
@if ($errors->any())
<div class="alert alert-danger mt-3">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('login') }}" method="post">
@csrf
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Correo electronico</label>
<input name="email" type="email" class="form-control" id="exampleInputEmail1"
aria-describedby="emailHelp">
<div id="emailHelp" class="form-text"></div>
</div>
<div class="mb-3">
<label for="exampleInputPassword1" class="form-label">Contraseña</label>
<input name="password" type="password" class="form-control" id="exampleInputPassword1">
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
</form>
</div>
</div>
</div>
<script src="{{ asset('plugins/global/plugins.bundle.js') }}"></script>
<script src="{{ asset('plugins/custom/prismjs/prismjs.bundle.js') }}"></script>
<script src="{{ asset('js/scripts.bundle.js') }}"></script>
<!--end::Global Theme Bundle-->
<!--begin::Page Vendors(used by this page)-->
<script src="{{ asset('plugins/custom/datatables/datatables.bundle.js') }}"></script>
<!--end::Page Vendor s-->
<!--begin::Page Scripts(used by this page)-->
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
// Este script es para obtener la api key
axios.get('api/get-token')
.then(function(response) {
localStorage.removeItem('amazonToken');
localStorage.setItem('amazonToken', response.data.access_token);
}).catch(error => {
console.error(error);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment