我正在尝试将下面的cURL转换为php cURL:
$ curl -X POST token \
public_token="$public_token_from_plaid_link_module“-d client_id="$plaid_client_id”\ -d secret="$plaid_secret“\ -d
使用此代码:
$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{“代码”:1100,“消息”:"client_id缺失“,”解决“:”包括您的客户端ID,以便我们知道您是谁“}
我不知道我的格式有什么问题,它使格子无法识别帖子的client_id部分。为进一步参考,我有更多的细节如下。
以下内容取自格子网站,可通过搜索“格子api快速启动”找到:
参考/exchange_token端点
/exchange_token端点在tartan和生产环境中都可用。方法端点所需参数在/exchange_token client_id、public_token account_id之后可选参数
/exchange_token端点已经集成到格子节点、格子-围棋、格子-红宝石和格子-python客户端库中。对格子-java的支持即将到来。
如果您正在使用一个尚不支持/exchange_token端点的库,则只需发出一个标准的HTTP请求:
$ curl -X POST token \
public_token="$public_token_from_plaid_link_module“-d client_id="$plaid_client_id”\ -d secret="$plaid_secret“\ -d
对于有效的请求,API将返回一个JSON响应,类似于:
{ "access_token":"foobar_plaid_access_token“}
发布于 2016-07-19 00:25:45
问题是您正在发送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");https://stackoverflow.com/questions/38447713
复制相似问题