Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Client\API;
- use \GuzzleHttp\Client;
- use Response;
- use Auth;
- class PelayananController extends Controller
- {
- public function __construct()
- {
- $this->client = new Client(['base_uri' => 'http://api.capstoneindonesia.net/v1/']);
- $response = $this->client->request('POST', 'login', [
- 'form_params' => [
- 'email' => 'arm.adrian02@gmail.comm',
- 'password' => '123123',
- ]
- ]);
- $token = $response->getBody()->getContents();
- $this->headers = [
- 'Authorization' => 'Bearer ' . $token,
- 'Accept' => 'application/json',
- ];
- }
- public function app(API $api, Request $request){
- /*$email = 'firman@gmail.com';
- $pass = 'admin';
- dd($api->login(['firman@gmail.com','admin']));*/
- /*$api->login('firman@gmail.com','admin');*/
- /*$api->post('login',['email'=>'firman@gmail.com','password'=>'admin']);*/
- /*$data = $api->login('firman@gmail.com','admin');
- return response()->json($data, 201);*/
- $about1 = $this->client->request('GET', 'about', [
- 'headers' => $this->headers
- ]);
- $about = json_decode($about1->getBody()->getContents(),true);
- return view('admin.about.index')->with('about', $about);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement