【问题标题】:Plaid API php cURL not sending post data格子 API php cURL 不发送帖子数据
【发布时间】:2016-11-21 17:02:24
【问题描述】:

我正在尝试将以下 cURL 转换为 php cURL:

$ curl -X POST https://tartan.plaid.com/exchange_token\

-d client_id="$plaid_client_id" \ -d 秘密="$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网站,可通过搜索“plaid api quickstart”找到:


参考 /exchange_token 端点

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

/exchange_token 端点已集成到 plaid-node、plaid-go、plaid-ruby 和 plaid-python 客户端库中。对 plaid-java 的支持即将推出。

如果您使用的库还不支持 /exchange_token 端点,您可以简单地发出标准 HTTP 请求:

$ curl -X POST https://tartan.plaid.com/exchange_token \

-d client_id="$plaid_client_id" \ -d 秘密="$plaid_secret" \ -d public_token="$public_token_from_plaid_link_module"

对于有效请求,API 将返回类似于以下内容的 JSON 响应:

{ “access_token”:“foobar_plaid_access_token” }


【问题讨论】:

    标签: php api curl plaid


    【解决方案1】:

    问题是您正在发送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");
    

    【讨论】:

    • 因为那封信,我生命中的许多小时都消失了。谢谢,很抱歉浪费您的时间...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-07
    • 2013-04-08
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    相关资源
    最近更新 更多