Created
August 10, 2017 07:19
-
-
Save ohvitorino/925e6f805d64e67bffb4678612897bf8 to your computer and use it in GitHub Desktop.
This a example of a curl request with basic authentication and x-www-form-urlencoded.
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 | |
$curl = curl_init(); | |
$header = []; | |
$header[] = 'Content-type: application/x-www-form-urlencoded'; | |
// user:password in base64 | |
$header[] = 'Authorization: Basic xxxxxx'; | |
curl_setopt($curl, CURLOPT_URL, 'http://url/user/add'); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); | |
curl_setopt($curl, CURLOPT_POST,true); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, 'id=888&email=xpto%40xpto.io&firstName=jonh&lastName=doe'); | |
$response = curl_exec($curl); | |
curl_close($curl); | |
var_dump($response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment