Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1.     /**
  2.      *@Route("/guzzle/", name="githubapi")
  3.      */
  4.     public function guzzle()
  5.     {
  6.         $client = new \GuzzleHttp\Client();
  7.         $request = $client->request(
  8.             'POST',
  9.             'http://127.0.0.1/posts', [
  10.             'body' => 'username=viiskies&password=flkfasljflaksdj'
  11.         ]);
  12.         $body = $request->getBody();
  13.  
  14.         $body = json_decode($body, true);
  15.         echo '<pre>';
  16.         var_dump($body);
  17.         echo '</pre>';
  18.         exit;
  19.     }
  20.  
  21.      /**
  22.       *@Route("/posts", methods="POST")
  23.       */
  24.     public function sendPost()
  25.     {
  26.         return new JsonResponse(['a45454564545' => 'b']);
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement