-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Expand file tree
/
Copy pathproxy-usage.php
More file actions
70 lines (56 loc) · 2.62 KB
/
Copy pathproxy-usage.php
File metadata and controls
70 lines (56 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace ccxt;
include_once (__DIR__.'/../../ccxt.php');
// ----------------------------------------------------------------------------
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
// -----------------------------------------------------------------------------
error_reporting(E_ALL);
date_default_timezone_set('UTC');
use ccxt\Precise;
use React\Async;
use React\Promise;
// 1) ABOUT CCXT PROXIES, READ MORE AT: https://docs.ccxt.com/README?id=proxy
// 2) in python, uncomment the below:
// if sys.platform == 'win32':
// asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
function example_proxy_url() {
return Async\async(function () {
$my_ex = new \ccxt\async\kucoin();
$my_ex->proxy_url = 'http://188.245.226.105:8090/proxy_url.php?caller=https://ccxt.com&url=';
var_dump(\React\Async\await($my_ex->fetch('https://api.ipify.org/')));
}) ();
}
function example_http_proxy() {
return Async\async(function () {
$my_ex = new \ccxt\async\kucoin();
$my_ex->http_proxy = 'http://188.245.226.105:8911'; // "httpProxy" or "httpsProxy" (depending on your proxy protocol)
var_dump(\React\Async\await($my_ex->fetch('https://api.ipify.org/')));
}) ();
}
function example_socks_proxy() {
return Async\async(function () {
$my_ex = new \ccxt\async\kucoin();
$my_ex->socks_proxy = 'socks5://127.0.0.1:1080'; // from protocols: socks, socks5, socks5h
var_dump(\React\Async\await($my_ex->fetch('https://api.ipify.org/')));
}) ();
}
function example_web_sockets() {
return Async\async(function () {
$my_ex = new \ccxt\pro\kucoin();
$my_ex->http_proxy = 'http://188.245.226.105:8911'; // even though you are using WebSockets, you might also need to set up proxy for the exchange's REST requests
$my_ex->ws_proxy = 'http://188.245.226.105:8911'; // "wsProxy" or "wssProxy" or "wsSocksProxy" (depending on your proxy protocol)
\React\Async\await($my_ex->load_markets());
//
// To ensure your WS proxy works, uncomment below code and watch the log
//
// myEx.verbose = true;
// await myEx.loadHttpProxyAgent ();
// await myEx.watch ('ws://188.245.226.105:9876/', 'myip'); // in the incoming logs, confirm that you see the proxy IP in "hello" message
//
var_dump(\React\Async\await($my_ex->watch_ticker('BTC/USDT')));
\React\Async\await($my_ex->close());
}) ();
}
// await example_proxyUrl ();
\React\Async\await(example_http_proxy());