Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'vendor/autoload.php';
- use GuzzleHttp\Client;
- if (isset($_POST['cari'])) {
- $client = new Client([
- 'base_uri' => 'https://api.deezer.com',
- ]);
- $response = $client->request('GET', 'https://api.deezer.com/search/track?q='.$_POST['cari']);
- $hasil = json_decode($response->getBody());
- $_SESSION['cari'] = $_POST['cari'];
- $_SESSION['total'] = $hasil->total;
- }
- if(isset($_GET['page'])){
- if($_GET['page'] == "0"){
- $client = new Client([
- 'base_uri' => 'https://api.deezer.com',
- ]);
- $response = $client->request('GET', 'https://api.deezer.com/search/track?q='.$_SESSION['cari']);
- $hasil = json_decode($response->getBody());
- $_SESSION['total'] = $hasil->total;
- }elseif (!empty($_GET['page'])) {
- $client = new Client([
- 'base_uri' => 'https://api.deezer.com',
- ]);
- $response = $client->request('GET', 'https://api.deezer.com/search/track?q='.$_SESSION['cari'].'&index='.$_GET['page']);
- $hasil = json_decode($response->getBody());
- $_SESSION['total'] = $hasil->total;
- }
- }
- if (!empty($_SESSION['total'])) {
- $page = isset($_GET['page'])?(int)$_GET['page'] : 0;
- $previous = $page - 25;
- $next = $page + 25;
- $total_page = $_SESSION['total'];
- }
Add Comment
Please, Sign In to add comment