格子 API php cURL 未发送 post 数据
Plaid API php cURL not sending post data
我正在尝试将以下 cURL 转换为 php cURL:
$ curl -X POST https://tartan.plaid.com/exchange_token \
-d client_id="$plaid_client_id" \
-d secret="$plaid_secret" \
-d public_token="$public_token_from_plaid_link_module"
使用此代码:
$data = array(
"cliend_id"=>"test_id",
"secret"=>"test_secret",
"public_token"=>"test,fidelity,connected");
$string = http_build_query($data);
echo $string;
//initialize session
$ch=curl_init("https://tartan.plaid.com/exchange_token");
//set options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute session
$exchangeToken = curl_exec($ch);
echo $exchangeToken;
//close session
curl_close($ch);
我收到了这样的回复:
cliend_id=test_id&secret=test_secret&public_token=test%2Cfidelity%2Cconnected{ "code": 1100, "message": "client_id missing", "resolve": "Include your Client ID so we know who you are." }
我不确定我的格式有什么问题导致格子无法识别 post 的 client_id 部分。为了进一步参考,我在下面有更多详细信息。
以下摘自格子站点,可搜索"plaid api quickstart":
参考
/exchange_token端点
/exchange_token 端点在格子呢和生产环境中均可用。
方法端点必需参数可选参数
POST /exchange_token client_id, 秘密, public_token account_id
/exchange_token 端点已经集成到 plaid-node、plaid-go、plaid-ruby 和 plaid-python 客户端库中。即将支持格子-java。
如果您正在使用尚不支持 /exchange_token 端点的库,您可以简单地发出标准 HTTP 请求:
$ curl -X POST https://tartan.plaid.com/exchange_token \
-d client_id="$plaid_client_id" \
-d secret="$plaid_secret" \
-d public_token="$public_token_from_plaid_link_module"
对于有效请求,API 将 return 一个 JSON 响应类似于:
{
"access_token": "foobar_plaid_access_token"
}
问题是您正在发送 cliend_id
但服务器期望 client_id
:
$data = array(
"client_id"=>"test_id", // Use client_id instead of cliend_id
"secret"=>"test_secret",
"public_token"=>"test,fidelity,connected");
我正在尝试将以下 cURL 转换为 php cURL:
$ curl -X POST https://tartan.plaid.com/exchange_token \
-d client_id="$plaid_client_id" \ -d secret="$plaid_secret" \ -d public_token="$public_token_from_plaid_link_module"
使用此代码:
$data = array(
"cliend_id"=>"test_id",
"secret"=>"test_secret",
"public_token"=>"test,fidelity,connected");
$string = http_build_query($data);
echo $string;
//initialize session
$ch=curl_init("https://tartan.plaid.com/exchange_token");
//set options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute session
$exchangeToken = curl_exec($ch);
echo $exchangeToken;
//close session
curl_close($ch);
我收到了这样的回复:
cliend_id=test_id&secret=test_secret&public_token=test%2Cfidelity%2Cconnected{ "code": 1100, "message": "client_id missing", "resolve": "Include your Client ID so we know who you are." }
我不确定我的格式有什么问题导致格子无法识别 post 的 client_id 部分。为了进一步参考,我在下面有更多详细信息。
以下摘自格子站点,可搜索"plaid api quickstart":
参考 /exchange_token端点
/exchange_token 端点在格子呢和生产环境中均可用。 方法端点必需参数可选参数 POST /exchange_token client_id, 秘密, public_token account_id
/exchange_token 端点已经集成到 plaid-node、plaid-go、plaid-ruby 和 plaid-python 客户端库中。即将支持格子-java。
如果您正在使用尚不支持 /exchange_token 端点的库,您可以简单地发出标准 HTTP 请求:
$ curl -X POST https://tartan.plaid.com/exchange_token \
-d client_id="$plaid_client_id" \ -d secret="$plaid_secret" \ -d public_token="$public_token_from_plaid_link_module"
对于有效请求,API 将 return 一个 JSON 响应类似于:
{ "access_token": "foobar_plaid_access_token" }
问题是您正在发送 cliend_id
但服务器期望 client_id
:
$data = array(
"client_id"=>"test_id", // Use client_id instead of cliend_id
"secret"=>"test_secret",
"public_token"=>"test,fidelity,connected");