Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url = 'http://87.233.64.194:8093/';
- $cUrl = curl_init($url);
- curl_setopt($cUrl, CURLOPT_POST, true);
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, array('content-type: text/plain','Accept: application/json'));
- curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, true);
- // *** WALLETS ***
- //wallet/block/get
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/block/get");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":1,"hash":"00000000000000140da9e6ecfc70a32e188940ced43ca9c5e14271247518a01c"}');
- $result = curl_exec($cUrl);
- echo "method: wallet/block/get result: " , $result;
- // wallet/chain
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/chain");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":1}');
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/chain result: " , $result;
- //wallet/address/watch
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/watch");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"address":"2N1wWrJe684AoL15dQUcoYiPegThmRR641o","type":1}');
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/address/watch \tresult: " , $result;
- // **** USERS ***
- // Create user, this will only give a true result once, as it will "fail" to
- // create duplicate users
- $userInfo = "{".
- "\"user\":".
- "{".
- "\"name\":\"John Doe\",".
- "\"role\":1,".
- "\"countryCode\":54,".
- "\"phoneNumber\":\"555-555-1234\",".
- "\"attributes\":".
- "{".
- "\"street\":\"123 Fake st\"".
- "}".
- "},".
- "\"userName\":\"apiUser\",".
- "\"unverifiedEmail\":\"apiUser@fake.com\",".
- "\"password\":\"NoMyPassword\"".
- "}";
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/create");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, $userInfo);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/create \t\tresult: " , $result, " // Returns false because user already exists";
- // ---- No Auth calls
- //user/verify/email
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/verify/email");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"emailToken":"fVXwVvjQIovXhVW4YBuQMQ=="}');
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/verify/email \tresult: " , $result, " // Result is 0 since the token isn't valid. A valid token is sent to email.";
- //user/password/reset
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/password/reset");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"userName":"apiUser","password":"NewPassword","emailToken":"ow71zup4Requbwua9I0trg=="}');
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/password/reset \tresult: " , $result , " // Result is 0 since the token isn't valid. A valid token is sent to email.";
- // --- Need auth to be successful
- // user/login
- $header = array();
- $header[] = 'Content-length: 58';
- $header[] = 'Content-type: application/json';
- $header[] = 'Authorization: Basic YXBpVXNlcjpOb015UGFzc3dvcmQ=';
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/login");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, 'grant_type=password&username=apiUser&password=NoMyPassword');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $header);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/login \t\tresult: " , $result;
- $json = json_decode($result,true);
- $token = $json['access_token'];
- //user/verify/cookie
- $header = array();
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/verify/cookie");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"token":"' . $token . '"}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $header);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/verify/cookie \tresult: " , $result;
- //auth/generate/apikey
- $headerBear = array();
- $headerBear[] = 'Content-length: 0';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/auth/generate/apikey");
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: auth/generate/apikey \tresult: " , $result;
- //deposit/address/get
- $headerBear = array();
- $headerBear[] = 'Content-length: 14';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/deposit/address/get");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":"btc"}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: deposit/address/get \tresult: " , $result;
- //user/disable
- $headerBear = array();
- $headerBear[] = 'Content-length: 23';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/disable");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"userName":"apiUser2"}');
- $result = curl_exec($cUrl);
- echo "\n\nmethod: user/disable \t\tresult: " , $result, " // Note: Will fail as a person an disable themselves, but then they won't be able to login again to enable, this is an admin type command";
- // **** Wallet endpoints with logins req ****
- //wallet/create
- $userName = "apiUser";
- $headerBear = array();
- $headerBear[] = 'Content-length: 27';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/create");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"name":"' . $userName . '","type":1}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/create \t\tresult: " , $result;
- $json = json_decode($result,true);
- // $btcAddress = $json['wallet']['accounts'];
- //wallet/address/verify
- $headerBear = array();
- $headerBear[] = 'Content-length: 58';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/verify");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"address":"2N9oxwWpP1z8joNmj2cub2wp6vhJUHkF4XL","type":1}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/address/verify \tresult: " , $result;
- //wallet/address/generate
- $headerBear = array();
- $headerBear[] = 'Content-length: 33';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/generate");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"name":"10011_apiUser","type":2}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/address/generate\tresult: " , $result;
- //wallet/address/add
- $headerBear = array();
- $headerBear[] = 'Content-length: 147';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/add");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"wallet":{"id":12,"type":1,"accounts":[{"id":10011,"name":"10011_apiUser","addresses":["2N1wWrJe684AoL15dQUcoYiPegThmRR641o"]}]},"onlyDbAdd":true}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/address/add \tresult: " , $result;
- //wallet/get
- $headerBear = array();
- $headerBear[] = 'Content-length: 18';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/get");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"id":12,"type":1}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/get \t\tresult: " , $result;
- //wallet/list
- $headerBear = array();
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/list");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"id":10011}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/list \t\tresult: " , $result;
- //wallet/tx/receipt
- // This one hangs the server at the moment. shouldn't need it anyways.
- // $headerBear = array();
- // $headerBear[] = 'Content-length: 20';
- // $headerBear[] = 'Content-type: application/json';
- // $headerBear[] = 'Authorization: Bearer ' . $token;
- // curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/receipt");
- // curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"hash":"","type":2}');
- // curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- // $result = curl_exec($cUrl);
- // echo "\n\nmethod: wallet/tx/receipt \tresult: " , $result;
- //wallet/tx/list
- $headerBear = array();
- $headerBear[] = 'Content-length: 130';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/list");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"wallet":{"id":12,"type":1,"accounts":[{"id":10011,"name":"10011_apiUser","addresses":["2N1wWrJe684AoL15dQUcoYiPegThmRR641o"]}]}}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/tx/list \t\tresult: " , $result;
- //wallet/tx/get
- $headerBear = array();
- $headerBear[] = 'Content-length: 32';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/get");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"hash":"hashGoesHere","type":1}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/tx/get \t\tresult: " , $result, " // There aren't any hashes for this account";
- // //wallet/sendto
- $headerBear = array();
- $headerBear[] = 'Content-length: 493';
- $headerBear[] = 'Content-type: application/json';
- $headerBear[] = 'Authorization: Bearer ' . $token;
- curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/sendto");
- curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"wallet":{"id":12,"type":1,"accounts":[{"id":10011,"name":"10011_apiUser","addresses":["2MvnuaDQQZHvUzEXLvy8MF7jEwLrBzfWeEH"]}]}, "destination":{"address":"2NB6eCJhBrKga7JzWP5vNmk5uACEqBcvFYe","wallet":{"id":-1,"type":0,"accounts":[]},"totalReceived":"0","totalSend":"0","balance":"0","unconfirmedBalance":"0","finalBalance":"0","confirmedCt":0,"unconfirmedCt":0}, "callback":"http://127.0.0.1:8095/wallet/callback/tx", "callbackEmail":"fake@fake.com", "amount":"2", "comment":"y", "data":""}');
- curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
- $result = curl_exec($cUrl);
- echo "\n\nmethod: wallet/sendto \t\tresult: " , $result;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement