繁体   English   中英

格子API php cURL不发送发布数据

[英]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”:“包括您的客户ID,这样我们就知道您是谁。” }

我不确定我的格式有什么问题,该格式使格子无法识别帖子的client_id部分。 为了进一步参考,我在下面有更多详细信息。

以下摘自可通过搜索“ plaid api quickstart”找到的格子站点:


参考/ exchange_token端点

/ exchange_token端点在格子呢和生产环境中均可用。 方法端点必需参数可选参数POST / exchange_token client_id,secret,public_token account_id

/ exchange_token端点已经集成到格子节点,格子去,格子红宝石和格子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将返回类似于以下内容的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");

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM