Created
June 30, 2020 04:27
-
-
Save robzlabz/c0a8dc2bb99581945a5cdec0f8d7492a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Support\Facades\Http; | |
// kirim request | |
Http::get('...'); | |
Http::post('...'); | |
Http::put('...'); | |
Http::delete('...'); | |
// kirim request query | |
Http::get('...', ['name' => 'Robbyn']); // => http://test.com?name=robbyn | |
Http::asForm()->post('...', ['name' => 'Robbyn']); // => http://test.com [form: name:robbyn ] | |
Http::asJson()->post('...', ['name' => 'Robbyn']); // => http://test.com {name:robbyn} | |
// kirim attachment | |
Http::attach('file_gambar', file_get_contents('file.jpg'), 'photo.jpg') | |
->post('...'); | |
// kirim attachment dengan stream | |
$photo = fopen('photo.jpg','r'); | |
Http::attach('file_gambar', $photo, 'photo.jpg')->post('...'); | |
// kirim request dengan accept header | |
Http::accept('application/json')->post('...'); | |
Http::acceptJson()->post('...'); | |
// kirim dengan headers | |
Http::withHeaders(['Authorization' => 'Bearer XXX', 'X-Validation' => 'user123']) | |
->post('...'); | |
// basic auth | |
Http::withBasicAuth('[email protected]','password')->post('...'); | |
// digest auth | |
Http::withDigestAuth('[email protected]','password')->post('...'); | |
// Bearer Token | |
Http::withToken('user-token')->post('...'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment