Advertisement
Mr-roz3r

Untitled

Feb 12th, 2019
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6. use App\Client\API;
  7. use \GuzzleHttp\Client;
  8. use Response;
  9. use Auth;
  10.  
  11. class PelayananController extends Controller
  12. {
  13. public function __construct()
  14. {
  15. $this->client = new Client(['base_uri' => 'http://api.capstoneindonesia.net/v1/']);
  16. $response = $this->client->request('POST', 'login', [
  17. 'form_params' => [
  18. 'email' => 'arm.adrian02@gmail.comm',
  19. 'password' => '123123',
  20. ]
  21. ]);
  22. $token = $response->getBody()->getContents();
  23. $this->headers = [
  24. 'Authorization' => 'Bearer ' . $token,
  25. 'Accept' => 'application/json',
  26. ];
  27. }
  28.  
  29. public function app(API $api, Request $request){
  30. /*$email = 'firman@gmail.com';
  31. $pass = 'admin';
  32. dd($api->login(['firman@gmail.com','admin']));*/
  33. /*$api->login('firman@gmail.com','admin');*/
  34. /*$api->post('login',['email'=>'firman@gmail.com','password'=>'admin']);*/
  35. /*$data = $api->login('firman@gmail.com','admin');
  36. return response()->json($data, 201);*/
  37.  
  38. $about1 = $this->client->request('GET', 'about', [
  39. 'headers' => $this->headers
  40. ]);
  41. $about = json_decode($about1->getBody()->getContents(),true);
  42. return view('admin.about.index')->with('about', $about);
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement