こんにちは、私は再び戻ってきた誰もが、私の最後のポストでは、私は、SOAP API(Integrating Dwolla with PHP with their API)を使用しようとしましたが、私はSOAP APIは非推奨と明らかにDwollaは、REST/oAuth2.0たような、より効率的な方法がありますされてい私は今日、残り2週間で残りのAPIを使用する方法を尋ねています。私は本当にこれを学びたいと思っています。DwollaのAPIでお金を送って、PHPでそれをやりますか?
まず第一に、私は私が成功した私は何の問題それをやってを持っていないaccess_tokenはを取得することができたと言うことでしょう。問題は、私がSend Endpoint(https://www.dwolla.com/developers/endpoints/accountapi/send)を使って基本的にお金を送ろうとするときです。私の正確な問題は、決して成功した回答を得ることができないことです。偽またはエラーメッセージの応答のみ。
だから私は持っているインデックス・ページ上のリンク「あなたの口座に資金を追加します」。その後、ウェブサイトが求めている権限を受け入れるアカウントユーザーがそのリンクをクリックし、それは彼らのDwollaにサインインするためにそれらを受け入れるDwollaページにそれらを取るでしょう。ユーザーが「同意」を押すと、選択したURLにリダイレクトされ、承認のために使用するaccess_tokenが返されます。ここに私のコードである
<?php
//Define variables
$key = 'redacted';
$secret = 'redacted';
$dwolla_client_id = urlencode($key);
$dwolla_secret_key = urlencode($secret);
$code = urlencode($_GET["code"]);
//get token
$retireve_token = file_get_contents("https://www.dwolla.com/oauth/v2/token?client_id=".$dwolla_client_id."&client_secret=".$dwolla_secret_key."&grant_type=authorization_code&redirect_uri=http://localhost/purchase_order.php&code=".$code);
$decoded_json = json_decode($retireve_token, true);
var_dump($decoded_json);
if($decoded_json["access_token"]){
$arr = '{
"oauth_token": "'.$decoded_json["access_token"].'",
"fundsSource": "balance",
"pin": "1111",
"notes": "Payment for services rendered",
"amount": 1.01,
"destinationId": "812-111-1111",
"assumeCosts": false,
"facilitatorAmount": 0,
"destinationType": "dwolla"
}';
$opts = array('http'=>array('method'=>"POST",'content'=> $arr, 'header' => 'Content-Type: application/json'));
$ctx = stream_context_create($opts);
$send_request = file_get_contents('https://www.dwolla.com/oauth/rest/accountapi/send', false, $ctx);
var_dump(json_decode($send_request));
}
?>
Iは、例えば、このようなメッセージを受信する(これはDwollaがあまりにリダイレクトしすぎaccess_tokenはを送信するページがある)
アレイ(1){[ "access_tokenは"] = >文字列(50) "編集済み"}警告: のfile_get_contents(https://www.dwolla.com/oauth/rest/accountapi/send): ストリームをオープンに失敗しました:HTTP要求に失敗しました! HTTP/1.1 503サービス ライン47 NULL
ありがとう:D – Xenland
そのすべての良い私は私の資格情報を更新しなかったし、古いものは、あなたのログに基づいて、もはや – Xenland
有効で、私はあなたがdwollaに尋ねるべきだと思います。それは503 Service Unavailableです。これは、サーバーに問題があるという手がかりを与えます。 – ariefbayu