Advertisement
shadley7

Untitled

Jul 6th, 2018
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.41 KB | None | 0 0
  1. <?php
  2.  
  3. $url = 'http://87.233.64.194:8093/';
  4. $cUrl = curl_init($url);
  5.  
  6.  
  7.  
  8. curl_setopt($cUrl, CURLOPT_POST, true);
  9. curl_setopt($cUrl, CURLOPT_HTTPHEADER, array('content-type: text/plain','Accept: application/json'));
  10. curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, true);
  11.  
  12. // *** WALLETS ***
  13.  
  14. //wallet/block/get
  15. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/block/get");
  16. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":1,"hash":"00000000000000140da9e6ecfc70a32e188940ced43ca9c5e14271247518a01c"}');
  17. $result = curl_exec($cUrl);
  18. echo "method: wallet/block/get result: " , $result;
  19.  
  20. // wallet/chain
  21. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/chain");
  22. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":1}');
  23. $result = curl_exec($cUrl);
  24. echo "\n\nmethod: wallet/chain result: " , $result;
  25.  
  26. //wallet/address/watch
  27. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/watch");
  28. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"address":"2N1wWrJe684AoL15dQUcoYiPegThmRR641o","type":1}');
  29. $result = curl_exec($cUrl);
  30. echo "\n\nmethod: wallet/address/watch \tresult: " , $result;
  31.  
  32. // **** USERS ***
  33.  
  34. // Create user, this will only give a true result once, as it will "fail" to
  35. // create duplicate users
  36. $userInfo = "{".
  37. "\"user\":".
  38. "{".
  39. "\"name\":\"John Doe\",".
  40. "\"role\":1,".
  41. "\"countryCode\":54,".
  42. "\"phoneNumber\":\"555-555-1234\",".
  43. "\"attributes\":".
  44. "{".
  45. "\"street\":\"123 Fake st\"".
  46. "}".
  47. "},".
  48. "\"userName\":\"apiUser\",".
  49. "\"unverifiedEmail\":\"apiUser@fake.com\",".
  50. "\"password\":\"NoMyPassword\"".
  51. "}";
  52. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/create");
  53. curl_setopt($cUrl, CURLOPT_POSTFIELDS, $userInfo);
  54. $result = curl_exec($cUrl);
  55. echo "\n\nmethod: user/create \t\tresult: " , $result, " // Returns false because user already exists";
  56.  
  57. // ---- No Auth calls
  58.  
  59. //user/verify/email
  60. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/verify/email");
  61. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"emailToken":"fVXwVvjQIovXhVW4YBuQMQ=="}');
  62. $result = curl_exec($cUrl);
  63. echo "\n\nmethod: user/verify/email \tresult: " , $result, " // Result is 0 since the token isn't valid. A valid token is sent to email.";
  64.  
  65. //user/password/reset
  66. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/password/reset");
  67. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"userName":"apiUser","password":"NewPassword","emailToken":"ow71zup4Requbwua9I0trg=="}');
  68. $result = curl_exec($cUrl);
  69. echo "\n\nmethod: user/password/reset \tresult: " , $result , " // Result is 0 since the token isn't valid. A valid token is sent to email.";
  70.  
  71.  
  72.  
  73. // --- Need auth to be successful
  74.  
  75. // user/login
  76. $header = array();
  77. $header[] = 'Content-length: 58';
  78. $header[] = 'Content-type: application/json';
  79. $header[] = 'Authorization: Basic YXBpVXNlcjpOb015UGFzc3dvcmQ=';
  80. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/login");
  81. curl_setopt($cUrl, CURLOPT_POSTFIELDS, 'grant_type=password&username=apiUser&password=NoMyPassword');
  82. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $header);
  83. $result = curl_exec($cUrl);
  84. echo "\n\nmethod: user/login \t\tresult: " , $result;
  85. $json = json_decode($result,true);
  86. $token = $json['access_token'];
  87.  
  88. //user/verify/cookie
  89. $header = array();
  90. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/verify/cookie");
  91. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"token":"' . $token . '"}');
  92. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $header);
  93. $result = curl_exec($cUrl);
  94. echo "\n\nmethod: user/verify/cookie \tresult: " , $result;
  95.  
  96. //auth/generate/apikey
  97. $headerBear = array();
  98. $headerBear[] = 'Content-length: 0';
  99. $headerBear[] = 'Content-type: application/json';
  100. $headerBear[] = 'Authorization: Bearer ' . $token;
  101. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/auth/generate/apikey");
  102. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  103. $result = curl_exec($cUrl);
  104. echo "\n\nmethod: auth/generate/apikey \tresult: " , $result;
  105.  
  106. //deposit/address/get
  107. $headerBear = array();
  108. $headerBear[] = 'Content-length: 14';
  109. $headerBear[] = 'Content-type: application/json';
  110. $headerBear[] = 'Authorization: Bearer ' . $token;
  111. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/deposit/address/get");
  112. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"type":"btc"}');
  113. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  114. $result = curl_exec($cUrl);
  115. echo "\n\nmethod: deposit/address/get \tresult: " , $result;
  116.  
  117. //user/disable
  118. $headerBear = array();
  119. $headerBear[] = 'Content-length: 23';
  120. $headerBear[] = 'Content-type: application/json';
  121. $headerBear[] = 'Authorization: Bearer ' . $token;
  122. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  123. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/user/disable");
  124. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"userName":"apiUser2"}');
  125. $result = curl_exec($cUrl);
  126.  
  127. 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";
  128.  
  129. // **** Wallet endpoints with logins req ****
  130. //wallet/create
  131. $userName = "apiUser";
  132. $headerBear = array();
  133. $headerBear[] = 'Content-length: 27';
  134. $headerBear[] = 'Content-type: application/json';
  135. $headerBear[] = 'Authorization: Bearer ' . $token;
  136. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/create");
  137. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"name":"' . $userName . '","type":1}');
  138. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  139. $result = curl_exec($cUrl);
  140. echo "\n\nmethod: wallet/create \t\tresult: " , $result;
  141. $json = json_decode($result,true);
  142. // $btcAddress = $json['wallet']['accounts'];
  143.  
  144. //wallet/address/verify
  145. $headerBear = array();
  146. $headerBear[] = 'Content-length: 58';
  147. $headerBear[] = 'Content-type: application/json';
  148. $headerBear[] = 'Authorization: Bearer ' . $token;
  149. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/verify");
  150. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"address":"2N9oxwWpP1z8joNmj2cub2wp6vhJUHkF4XL","type":1}');
  151. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  152. $result = curl_exec($cUrl);
  153. echo "\n\nmethod: wallet/address/verify \tresult: " , $result;
  154.  
  155. //wallet/address/generate
  156. $headerBear = array();
  157. $headerBear[] = 'Content-length: 33';
  158. $headerBear[] = 'Content-type: application/json';
  159. $headerBear[] = 'Authorization: Bearer ' . $token;
  160. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/generate");
  161. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"name":"10011_apiUser","type":2}');
  162. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  163. $result = curl_exec($cUrl);
  164. echo "\n\nmethod: wallet/address/generate\tresult: " , $result;
  165.  
  166. //wallet/address/add
  167. $headerBear = array();
  168. $headerBear[] = 'Content-length: 147';
  169. $headerBear[] = 'Content-type: application/json';
  170. $headerBear[] = 'Authorization: Bearer ' . $token;
  171. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/address/add");
  172. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"wallet":{"id":12,"type":1,"accounts":[{"id":10011,"name":"10011_apiUser","addresses":["2N1wWrJe684AoL15dQUcoYiPegThmRR641o"]}]},"onlyDbAdd":true}');
  173. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  174. $result = curl_exec($cUrl);
  175. echo "\n\nmethod: wallet/address/add \tresult: " , $result;
  176.  
  177. //wallet/get
  178. $headerBear = array();
  179. $headerBear[] = 'Content-length: 18';
  180. $headerBear[] = 'Content-type: application/json';
  181. $headerBear[] = 'Authorization: Bearer ' . $token;
  182. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/get");
  183. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"id":12,"type":1}');
  184. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  185. $result = curl_exec($cUrl);
  186. echo "\n\nmethod: wallet/get \t\tresult: " , $result;
  187.  
  188. //wallet/list
  189. $headerBear = array();
  190. $headerBear[] = 'Content-type: application/json';
  191. $headerBear[] = 'Authorization: Bearer ' . $token;
  192. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/list");
  193. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"id":10011}');
  194. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  195. $result = curl_exec($cUrl);
  196. echo "\n\nmethod: wallet/list \t\tresult: " , $result;
  197.  
  198. //wallet/tx/receipt
  199. // This one hangs the server at the moment. shouldn't need it anyways.
  200. // $headerBear = array();
  201. // $headerBear[] = 'Content-length: 20';
  202. // $headerBear[] = 'Content-type: application/json';
  203. // $headerBear[] = 'Authorization: Bearer ' . $token;
  204. // curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/receipt");
  205. // curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"hash":"","type":2}');
  206. // curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  207. // $result = curl_exec($cUrl);
  208. // echo "\n\nmethod: wallet/tx/receipt \tresult: " , $result;
  209.  
  210. //wallet/tx/list
  211. $headerBear = array();
  212. $headerBear[] = 'Content-length: 130';
  213. $headerBear[] = 'Content-type: application/json';
  214. $headerBear[] = 'Authorization: Bearer ' . $token;
  215. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/list");
  216. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"wallet":{"id":12,"type":1,"accounts":[{"id":10011,"name":"10011_apiUser","addresses":["2N1wWrJe684AoL15dQUcoYiPegThmRR641o"]}]}}');
  217. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  218. $result = curl_exec($cUrl);
  219. echo "\n\nmethod: wallet/tx/list \t\tresult: " , $result;
  220.  
  221. //wallet/tx/get
  222. $headerBear = array();
  223. $headerBear[] = 'Content-length: 32';
  224. $headerBear[] = 'Content-type: application/json';
  225. $headerBear[] = 'Authorization: Bearer ' . $token;
  226. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/tx/get");
  227. curl_setopt($cUrl, CURLOPT_POSTFIELDS, '{"hash":"hashGoesHere","type":1}');
  228. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  229. $result = curl_exec($cUrl);
  230. echo "\n\nmethod: wallet/tx/get \t\tresult: " , $result, " // There aren't any hashes for this account";
  231.  
  232. // //wallet/sendto
  233. $headerBear = array();
  234. $headerBear[] = 'Content-length: 493';
  235. $headerBear[] = 'Content-type: application/json';
  236. $headerBear[] = 'Authorization: Bearer ' . $token;
  237. curl_setopt($cUrl, CURLOPT_URL, $url . "v1/wallet/sendto");
  238. 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":""}');
  239. curl_setopt($cUrl, CURLOPT_HTTPHEADER, $headerBear);
  240. $result = curl_exec($cUrl);
  241. echo "\n\nmethod: wallet/sendto \t\tresult: " , $result;
  242.  
  243. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement