Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $clientid = 'a';
- $secretkey = 'b';
- $redirect = 'http://return.to/apage.php';
- if(isset($_GET['code'])) {
- $code = urlencode($_GET["code"]);
- } else {
- header("Location: https://www.dwolla.com/oauth/v2/authenticate?client_id=".urlencode($clientid)."&response_type=code&redirect_uri=".urlencode($redirect)."&scope=send%7Ctransactions"); exit;
- }
- # fetch auth token
- $url = "https://www.dwolla.com/oauth/v2/token?client_id=".urlencode($clientid)."&client_secret=".urlencode($secretkey)."&grant_type=authorization_code&code=".$code."&redirect_uri=".urlencode($redirect);
- $tok = file_get_contents($url);
- $json = json_decode($tok, true);
- # do a send
- $target = 'https://www.dwolla.com/oauth/rest/accountapi/send';
- $array = array(
- 'oauth_token' => $json['access_token'],
- 'pin' => '1234',
- 'destinationId' => '812-111-1111',
- 'amount' => 1,
- 'facilitatorAmount' => 0,
- 'notes' => 'Test'
- );
- $curl = curl_init($target);
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($array));
- $response = curl_exec($curl); print_r($response); exit;
- $json = json_decode(curl_exec($curl), true);
- curl_close($curl);
- print_r($json); exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement