Created
April 29, 2020 10:08
-
-
Save rahuladams/9f9c56a5779870fbba695438db3017b0 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
$params = array ( | |
'parameter_one' => 'some_value', | |
'parameter_two' => | |
array ( | |
'parameter_array_option' => $some_variable, | |
) | |
); | |
//JSON encoded | |
$payload = json_encode($params); | |
$curl = curl_init(); | |
$url = $data['url']; | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => "https://API_URL", | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => "", | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 0, | |
CURLOPT_FOLLOWLOCATION => true, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => "POST", | |
CURLOPT_POSTFIELDS => $payload, | |
CURLOPT_HTTPHEADER => array( | |
"Content-Type: application/json" | |
), | |
)); | |
$response = curl_exec($curl); | |
//echo $response; | |
curl_close($curl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment