Bash CURL to php Bash CURL to php curl curl

Bash CURL to php


You can use this way. Keep in mind that you are posting the parameters. So the query string should not be attached to the URL but sent as post parameters

$data = array(    'grant_type' => 'password',    'scope' => 'api',    'username' => 'user@example.uri',    'password' => 'p...d');$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "https://someurl.com/oauth/token");$headers = array();$headers[] = "Authorization: Basic ZnVydGFzdGljLTZhMTAzNTE4Y2YyOGNhNmI3OTNhYzljNmJjM";curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS,    http_build_query($data));curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_TIMEOUT, 0);echo $response = curl_exec($ch);