Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

laravel send http post request json

use GuzzleHttpClient;
class yourController extends Controller {

    public function saveApiData()
    {
        $client = new Client();
        $res = $client->request('POST', 'https://url_to_the_api', [
            'form_params' => [
                'client_id' => 'test_id',
                'secret' => 'test_secret',
            ]
        ]);
        echo $res->getStatusCode();
        // 200
        echo $res->getHeader('content-type');
        // 'application/json; charset=utf8'
        echo $res->getBody();
        // {"type":"User"...'
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: import image as component react 
Javascript :: regex remove spaces 
Javascript :: javascript if string empty 
Javascript :: kendo template multiselect default selected 
Javascript :: wait for element to load javascript 
Javascript :: jquery set span text by id 
Javascript :: js function string parameter 
Javascript :: suppress spaces in front and in the end of a string javascript 
Javascript :: get first 10 characters of string javascript 
Javascript :: change p text jqwuery 
Javascript :: fetch api in js 
Javascript :: angularjs datetime 
Javascript :: html close tab 
Javascript :: javascript tofixed is not a function 
Javascript :: javascript returning a function 
Javascript :: nginx react router 
Javascript :: how to access curl data in javascript 
Javascript :: How to get current time zone in javascript 
Javascript :: object values 
Javascript :: javascript get sub array 
Javascript :: build apk from react native 
Javascript :: dm command discord.js 
Javascript :: how to create a folder using fs in node js 
Javascript :: javascript wait for element 
Javascript :: ts node cannot use import statement outside a module 
Javascript :: insert property multiple documents mongodb 
Javascript :: largest sum contiguous subarray javascript 
Javascript :: document queryselectorall and map javacript 
Javascript :: difference between library and framework in javascript 
Javascript :: png to base64 javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =