Search
 
SCRIPT & CODE EXAMPLE
 

PHP

guzzle post request with data

$response = $client->request('POST', 'http://httpbin.org/post', [
    'form_params' => [
        'field_name' => 'abc',
        'other_field' => '123',
        'nested_field' => [
            'nested' => 'hello'
        ]
    ]
]);
Comment

guzzlehttp form data

$client = new GuzzleHttpClient();
$response = $client->request('POST', 'http://www.example.com/user/create', [
    'form_params' => [
        'email' => 'test@gmail.com',
        'name' => 'Test user',
        'password' => 'testpassword',
    ]
]);
Comment

guzzle Request with POST files

$response = $client->request('POST', 'http://www.example.com/files/post', [
    'multipart' => [
        [
            'name'     => 'file_name',
            'contents' => fopen('/path/to/file', 'r')
        ],
        [
            'name'     => 'csv_header',
            'contents' => 'First Name, Last Name, Username',
            'filename' => 'csv_header.csv'
        ]
    ]
]);
Comment

guzzle get request

$client = new Client([(['base_uri' => 'https://reqres.in/']);

$response = $client->request('GET', '/api/users?page=1');
        
echo $response->getBody();
Comment

guzzlehttp form data

$response = $client->request('POST', 'http://www.example.com/files/post', [
    'multipart' => [
        [
            'name'     => 'file_name',
            'contents' => fopen('/path/to/file', 'r')
        ],
        [
            'name'     => 'csv_header',
            'contents' => 'First Name, Last Name, Username',
            'filename' => 'csv_header.csv'
        ]
    ]
]);
Comment

PREVIOUS NEXT
Code Example
Php :: php get all url parameters 
Php :: start php session 
Php :: php konstanten 
Php :: run composer with different php version 
Php :: unset session in php 
Php :: count sql query in php 
Php :: php artisan drop table 
Php :: twig ternary 
Php :: php capitalize each word 
Php :: php header location not working 
Php :: alter mysql 8 user root phpmyadmin first install 
Php :: grenerating random text color for text for image php 
Php :: laravel blade file naming conventine 
Php :: mysql count rows php 
Php :: how to calculate days difference between two dates in php 
Php :: ci db query error 
Php :: laravel update and insert transaction 
Php :: php add to associative array 
Php :: display image in laravel 
Php :: unable to locate package php8.1 ubuntu 
Php :: disable quantity field in woocommerce 
Php :: laravel 8 date difference in days 
Php :: php shell script 
Php :: php to call javascript function 
Php :: woocommerce product object 
Php :: valet laravel 
Php :: get all artisan commands 
Php :: php print array new line 
Php :: laravel share on whatsapp link 
Php :: php loop through array of objects 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =