简体   繁体   English

将 curl 转换为 php OAuth2.0 令牌生成错误

[英]convert curl to php OAuth2.0 Token Generate Error

<?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 curl --cert /etc/apache2/ssl/thasaix/thasaix_com.crt
--key /etc/apache2/ssl/thasaix/thasaix.com.key --key /etc/apache2/ssl/thasaix/thasaix.com.key
--location --request POST 'https://openapi-test.kasikornbank.com/v2/oauth/token' --location --request POST 'https://openapi-test.kasikornbank.com/v2/oauth/token'
--header 'Content-Type: application/x-www-form-urlencoded' --header '内容类型:应用程序/x-www-form-urlencoded'
--header 'Authorization: Basic R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy' --header '授权:基本 R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy'
--data-urlencode 'grant_type=client_credentials' --data-urlencode 'grant_type=client_credentials'

the result is结果是

{ "code": "openapi_error", "message": "OAuth2.0 Token Generate Error" } { "code": "openapi_error", "message": "OAuth2.0 令牌生成错误" }

use these headers like使用这些标题

curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Authorization: Basic R1FRWkZWcGpJQ0E5Y2xScUFQZVowODhSQTVYTFgzNzk6QTNLNkxjVHU3OTZ1QTZtxxyy',
    'Content-Type: application/x-www-form-urlencoded')
);

--data-urlencode 'grant_type=client_credentials' --data-urlencode 'grant_type=client_credentials'

Should be body part then I change code and it work应该是正文部分然后我更改代码并且它可以工作

curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=client_credentials");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PHP cURL在标头和POST JSON数据中发送oauth2.0 access_token - PHP cURL send oauth2.0 access_token in header and POST json data 使用PHP cURL获取access_token时,Google OAuth2.0返回“ invalid_request” - Google OAuth2.0 returns 'invalid_request' when getting access_token with PHP cURL 如何包含sope数据以生成访问令牌Oauth2.0? - How to include the sope datas to generate an access token Oauth2.0? 在Oauth2.0中刷新令牌 - Refresh token in Oauth2.0 (PHP)Oauth2.0-错误401 Google通讯录API - (PHP) Oauth2.0 - Error 401 Google Contacts API Google OAuth2.0 php客户端使用刷新令牌交换访问令牌 - Google OAuth2.0 php client exchange access token with refresh token 在后端使用 PHP 和 curl 为 Spotify 进行中央 OAuth2.0 授权 WebA ZDB9742CE18718Z - Central OAuth2.0 Authorization on the Backend-Side using PHP and curl for Spotify Web API PHP Adob​​eSign API ::具有OAuth2.0的transientDocuments - PHP AdobeSign API :: transientDocuments with OAuth2.0 Linkedin REST API:使用CRON作业中的php更新OAuth2.0访问令牌吗? - Linkedin REST API: Update OAuth2.0 Access token using php from a CRON job? PHP中的Oauth2.0服务器非常简单的实现-在POST中使用access_token - Oauth2.0 server in php very simple implementation - use access_token with POST
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM