Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

curl post laravel

<?php

  

namespace AppHttpControllers;

  

use IlluminateSupportFacadesHttp;

  

class ITSController extends Controller

{

    /**

     * Write code on Method

     *

     * @return response()

     */

    public function index()

    {

        $apiURL = 'https://api.mywebtuts.com/api/users';

        $postInput = [

            'first_name' => 'Hardik',

            'last_name' => 'Savani',

            'email' => 'example@gmail.com'

        ];

  

        $headers = [

            'X-header' => 'value'

        ];

  

        $response = Http::withHeaders($headers)->post($apiURL, $postInput);

  

        $statusCode = $response->status();

        $responseBody = json_decode($response->getBody(), true);

     

        dd($responseBody);

    }

}
Source by www.itsolutionstuff.com #
 
PREVIOUS NEXT
Tagged: #curl #post #laravel
ADD COMMENT
Topic
Name
1+4 =