Bagosep

Tes

Mar 30th, 2022
1,189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6. use GuzzleHttp\Client;
  7.  
  8. class TestingController extends Controller
  9. {
  10.     public function login()
  11.     {
  12.         $client = new Client();
  13.  
  14.         $url = "https://api.itats.ac.id/api/login-mahasiswa";
  15.  
  16.         $getResponse = $client->post($url,
  17.         [
  18.             'headers' => [
  19.                 'Accept' => 'application/json',
  20.             ],
  21.             'json' => [
  22.                 'name' => '06.2016.1.06628', //npm ku
  23.                 'pass' => '06.2016.1.06628', //password sim
  24.             ]
  25.            
  26.         ]);
  27.  
  28.         $response = json_decode($getResponse->getBody()->getContents(), true);
  29.        
  30.         dd($response);
  31.     }
  32.  
  33.     public function mahasiswa()
  34.     {
  35.         $client = new Client();
  36.  
  37.         $token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXBpLml0YXRzLmFjLmlkXC9hcGlcL2xvZ2luLW1haGFzaXN3YSIsImlhdCI6MTY0ODY0NDI1NSwiZXhwIjoxNjQ4NjQ3ODU1LCJuYmYiOjE2NDg2NDQyNTUsImp0aSI6IkVvUGRMVG1xOWdtdkRSbXYiLCJzdWIiOjM3MDM1LCJwcnYiOiIyM2JkNWM4OTQ5ZjYwMGFkYjM5ZTcwMWM0MDA4NzJkYjdhNTk3NmY3In0.6EdBk4AtTtvgtvi-Dfsm-6BJ0PJVeuOGTALkEKvoEVU';
  38.  
  39.         $url = "https://api.itats.ac.id/api/profil-mahasiswa?token=" . $token;
  40.  
  41.         $getResponse = $client->get($url,
  42.         [
  43.             'headers' => [
  44.                 'Accept' => 'application/json',
  45.             ]
  46.         ]);
  47.  
  48.         $response = json_decode($getResponse->getBody(), true);
  49.        
  50.         dd($response['data']['mhsnama']);
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment