Last active
November 21, 2020 08:19
-
-
Save ahelja/e229c218598836d23a5c to your computer and use it in GitHub Desktop.
Curl less method PHP
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
$url = 'http://server.com/path'; | |
$data = array('key1' => 'value1', 'key2' => 'value2'); | |
// use key 'http' even if you send the request to https://... | |
$options = array( | |
'http' => array( | |
'header' => "Content-type: application/x-www-form-urlencoded\r\n", | |
'method' => 'POST', | |
'content' => http_build_query($data), | |
), | |
); | |
$context = stream_context_create($options); | |
$result = file_get_contents($url, false, $context); | |
var_dump($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment