如何将此 cURL 转换为 PHP cURL?
How can I transform this cURL into PHP cURL?
将其作为 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"
}
]
}
试试这个:
$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%20card%7B%7BpAddressForClientSideOperations%7D%7Buser-token%7D%7BclientSessionTokenAllowedOrigin%7D\'',
CURLOPT_HTTPHEADER => array(
'Authorization: Basic {token}',
'Content-Type: application/x-www-form-urlencoded'
),));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
您可以使用 Postman 轻松完成此转换。
将其作为 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"
}
]
}
试试这个:
$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%20card%7B%7BpAddressForClientSideOperations%7D%7Buser-token%7D%7BclientSessionTokenAllowedOrigin%7D\'',
CURLOPT_HTTPHEADER => array(
'Authorization: Basic {token}',
'Content-Type: application/x-www-form-urlencoded'
),));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
您可以使用 Postman 轻松完成此转换。