<?php
$certFile = "/etc/apache2/ssl/thasaix/thasaix_com.crt";
$keyFile = "/etc/apache2/ssl/thasaix/thasaix.com.key";
$curl = curl_init();
curl_setopt($curl, CURLOPT_SSLCERT, $certFile);
curl_setopt($curl, CURLOPT_SSLKEY, $keyFile);
curl_setopt($curl, CURLOPT_URL, 'https://openapi-test.kasikornbank.com/v2/oauth/token');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Authorization: Basic R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = array('grant_type' => 'client_credentials');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
print $response;
?>
curl --cert /etc/apache2/ssl/thasaix/thasaix_com.crt
--key /etc/apache2/ssl/thasaix/thasaix.com.key
--location --request POST 'https://openapi-test.kasikornbank的.com / V2 /的OAuth /令牌”
--header '內容-型別:應用程式/ x WWW的形式進行了urlencoded'
--header '授權:基本R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy'
--data-進行urlencode 'grant_type = client_credentials'
結果是
{ "code": "openapi_error", "message": "OAuth2.0 令牌生成錯誤" }
uj5u.com熱心網友回復:
使用這些標題,如
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Basic R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy',
'Content-Type: application/x-www-form-urlencoded')
);
uj5u.com熱心網友回復:
--data-urlencode 'grant_type=client_credentials'
應該是身體的一部分然后我更改代碼并且它作業
curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=client_credentials");
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/399392.html
