Home > Mobile >  How can I transform this cURL into PHP cURL?
How can I transform this cURL into PHP cURL?

Time:04-09

Whats the best way to put this as a PHP cURL?

  curl --location --request POST 'https://identity.mypayquicker.com/core/connect/token' 
    --header 'Authorization: Basic {token}' 
    --header 'Content-Type: application/x-www-form-urlencoded' 
    --data-urlencode 'grant_type=client_credentials' 
    --data-urlencode 'scope=client_side_operation card{{pAddressForClientSideOperations}{user-token}{clientSessionTokenAllowedOrigin}'",
          "language": "curl",
          "name": "Example Request"
        }
      ]
    }

CodePudding user response:

Try this:

$curl = curl_init();
curl_setopt_array($curl, array(
 CURLOPT_URL => 'https://identity.mypayquicker.com/core/connect/token',
 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 => 'grant_type=client_credentials&scope=client_side_operation card{{pAddressForClientSideOperations}{user-token}{clientSessionTokenAllowedOrigin}\'',
 CURLOPT_HTTPHEADER => array(
   'Authorization: Basic {token}',
   'Content-Type: application/x-www-form-urlencoded'
 ),));


$response = curl_exec($curl);
curl_close($curl);
echo $response;

You can easily do this conversion using Postman.

  • Related