0

以下の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 を含めてください。" }

plaid が投稿の client_id 部分を認識しないようにしているフォーマットの何が問題なのかわかりません。詳細については、以下を参照してください。

以下は、「plaid api quickstart」を検索して見つけることができる Plaid サイトからの抜粋です。


リファレンス /exchange_token エンドポイント

/exchange_token エンドポイントは、タータン環境と本番環境の両方で使用できます。メソッド エンドポイント 必須パラメータ オプション パラメータ 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 secret="$plaid_secret" \ -d public_token="$public_token_from_plaid_link_module"

有効なリクエストの場合、API は次のような JSON レスポンスを返します。

{ "access_token": "foobar_plaid_access_token" }


4

1 に答える 1

2

問題はあなたが送信していることです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");
于 2016-07-19T00:25:45.903 に答える