質問編集履歴
2
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,184 +12,190 @@
|
|
12
12
|
|
13
13
|
サンプルソースがRubyでPHPで使用したいので自分なりに変更してみましたがうまくいかないのでご協力をお願いします。
|
14
14
|
|
15
|
+
```error内容
|
16
|
+
|
17
|
+
error内容
|
18
|
+
|
19
|
+
Fatal error: Uncaught exception 'DomainException' with message 'Algorithm not supported' in
|
20
|
+
|
21
|
+
/home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php on line 191 DomainException: Algorithm not supported in
|
22
|
+
|
23
|
+
/home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php on line 191 Call Stack: 0.0015 236392 1. {main}()
|
24
|
+
|
25
|
+
/home/ubuntu/workspace/quoinex_balance.php:0 0.0143 270496 2. Firebase\JWT\JWT::encode() /home/ubuntu/workspace/quoinex_balance.php:31 0.0144 272128 3. Firebase\JWT\JWT::sign() /home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php:170
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
以下サンプルコード
|
32
|
+
|
33
|
+
```Ruby
|
34
|
+
|
35
|
+
require 'uri'
|
36
|
+
|
37
|
+
require 'net/http'
|
38
|
+
|
39
|
+
require 'time'
|
40
|
+
|
41
|
+
require 'jwt'
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
uri = URI.parse("https://api.quoine.com")
|
46
|
+
|
47
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
48
|
+
|
49
|
+
http.use_ssl = true
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
token_id = 'YOUR_API_TOKEN_ID'
|
54
|
+
|
55
|
+
user_secret = 'YOUR_API_SECRET'
|
56
|
+
|
57
|
+
path = '/orders?product_id=1'
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
auth_payload = {
|
62
|
+
|
63
|
+
path: path,
|
64
|
+
|
65
|
+
nonce: DateTime.now.strftime('%Q'),
|
66
|
+
|
67
|
+
token_id: token_id
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
signature = JWT.encode(auth_payload, user_secret, 'HS256')
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
request = Net::HTTP::Get.new(path)
|
78
|
+
|
79
|
+
request.add_field('X-Quoine-API-Version', '2')
|
80
|
+
|
81
|
+
request.add_field('X-Quoine-Auth', signature)
|
82
|
+
|
83
|
+
request.add_field('Content-Type', 'application/json')
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
response = http.request(request)
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
以下、PHPで私が書いたコード
|
94
|
+
|
15
95
|
```php
|
16
96
|
|
17
|
-
|
18
|
-
|
19
|
-
|
97
|
+
<?php
|
98
|
+
|
99
|
+
// https://developers.quoine.com/#authentication の仕様書に従い
|
100
|
+
|
101
|
+
//JSON Web Tokenを使用する
|
102
|
+
|
103
|
+
//composerをインストール(今回はWEBROOTの場所にインストール)
|
104
|
+
|
105
|
+
//linuxでコマンド入力$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
|
106
|
+
|
107
|
+
//linuxでコマンド入力$ php composer require firebase/php-jwt
|
108
|
+
|
109
|
+
include('./vendor/autoload.php');
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
//ライブラリーを読み込む
|
114
|
+
|
115
|
+
use \Firebase\JWT\JWT;
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
//API取得して入力(お金がないっていないので本物のコードです)
|
120
|
+
|
121
|
+
$key = '309637';
|
122
|
+
|
123
|
+
$secret = 'iUbiLYh1UFY5tMOF0D2A3bCpcI7ksSPBoQ3QkM1SfgL7TMa3IJ6ew8ooVfA3GpteE6+9JA7Tmb6XiqJ+7yMtTQ==';
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
// URL作成
|
128
|
+
|
129
|
+
$base_url = 'https://api.quoine.com';
|
130
|
+
|
131
|
+
$order_url = '/accounts/balance';
|
132
|
+
|
133
|
+
$url = $base_url . $order_url;
|
134
|
+
|
135
|
+
$version = '2';
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
//ヘッダー情報作成
|
140
|
+
|
141
|
+
$timestamp = time() . substr(microtime(), 2, 3);
|
142
|
+
|
143
|
+
$method = 'POST';
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
$jwt = JWT::encode('path:' .$order_url,'nonce:' .$timestamp,'token_id:' .$key);
|
148
|
+
|
149
|
+
$sign = JWT::decode($jwt, $secret, array('HS256'));
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
//確認用
|
154
|
+
|
155
|
+
print_r($sign."<br>");
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
$header = array(
|
160
|
+
|
161
|
+
'X-Quoine-API-Version:' . $version,
|
162
|
+
|
163
|
+
'X-Quoine-Auth:' . $sign,
|
164
|
+
|
165
|
+
'Content-Type:application/json',
|
166
|
+
|
167
|
+
//'Content-Length:'. strlen($body),
|
168
|
+
|
169
|
+
);
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
//確認用
|
174
|
+
|
175
|
+
print_r($header);
|
176
|
+
|
177
|
+
$context = stream_context_create(array(
|
178
|
+
|
179
|
+
'http' => array(
|
180
|
+
|
181
|
+
'method' => $method,
|
182
|
+
|
183
|
+
'header' => implode(PHP_EOL, $header),
|
184
|
+
|
185
|
+
// 'content' => $body,
|
186
|
+
|
187
|
+
)
|
188
|
+
|
189
|
+
));
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
// API呼び出し
|
194
|
+
|
195
|
+
$response = file_get_contents($url, false, $context);
|
196
|
+
|
197
|
+
$result = json_decode($response, true);
|
198
|
+
|
199
|
+
print_r($result);
|
20
200
|
|
21
201
|
```
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
以下サンプルコード
|
26
|
-
|
27
|
-
```Ruby
|
28
|
-
|
29
|
-
require 'uri'
|
30
|
-
|
31
|
-
require 'net/http'
|
32
|
-
|
33
|
-
require 'time'
|
34
|
-
|
35
|
-
require 'jwt'
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
uri = URI.parse("https://api.quoine.com")
|
40
|
-
|
41
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
42
|
-
|
43
|
-
http.use_ssl = true
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
token_id = 'YOUR_API_TOKEN_ID'
|
48
|
-
|
49
|
-
user_secret = 'YOUR_API_SECRET'
|
50
|
-
|
51
|
-
path = '/orders?product_id=1'
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
auth_payload = {
|
56
|
-
|
57
|
-
path: path,
|
58
|
-
|
59
|
-
nonce: DateTime.now.strftime('%Q'),
|
60
|
-
|
61
|
-
token_id: token_id
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
signature = JWT.encode(auth_payload, user_secret, 'HS256')
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
request = Net::HTTP::Get.new(path)
|
72
|
-
|
73
|
-
request.add_field('X-Quoine-API-Version', '2')
|
74
|
-
|
75
|
-
request.add_field('X-Quoine-Auth', signature)
|
76
|
-
|
77
|
-
request.add_field('Content-Type', 'application/json')
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
response = http.request(request)
|
82
|
-
|
83
|
-
```
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
以下、PHPで私が書いたコード
|
88
|
-
|
89
|
-
```php
|
90
|
-
|
91
|
-
<?php
|
92
|
-
|
93
|
-
// https://developers.quoine.com/#authentication の仕様書に従い
|
94
|
-
|
95
|
-
//JSON Web Tokenを使用する
|
96
|
-
|
97
|
-
//composerをインストール(今回はWEBROOTの場所にインストール)
|
98
|
-
|
99
|
-
//linuxでコマンド入力$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
|
100
|
-
|
101
|
-
//linuxでコマンド入力$ php composer require firebase/php-jwt
|
102
|
-
|
103
|
-
include('./vendor/autoload.php');
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
//ライブラリーを読み込む
|
108
|
-
|
109
|
-
use \Firebase\JWT\JWT;
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
//API取得して入力(お金がないっていないので本物のコードです)
|
114
|
-
|
115
|
-
$key = '309637';
|
116
|
-
|
117
|
-
$secret = 'iUbiLYh1UFY5tMOF0D2A3bCpcI7ksSPBoQ3QkM1SfgL7TMa3IJ6ew8ooVfA3GpteE6+9JA7Tmb6XiqJ+7yMtTQ==';
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
// URL作成
|
122
|
-
|
123
|
-
$base_url = 'https://api.quoine.com';
|
124
|
-
|
125
|
-
$order_url = '/accounts/balance';
|
126
|
-
|
127
|
-
$url = $base_url . $order_url;
|
128
|
-
|
129
|
-
$version = '2';
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
//ヘッダー情報作成
|
134
|
-
|
135
|
-
$timestamp = time() . substr(microtime(), 2, 3);
|
136
|
-
|
137
|
-
$method = 'POST';
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
$jwt = JWT::encode('path:' .$order_url,'nonce:' .$timestamp,'token_id:' .$key);
|
142
|
-
|
143
|
-
$sign = JWT::decode($jwt, $secret, array('HS256'));
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
//確認用
|
148
|
-
|
149
|
-
print_r($sign."<br>");
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
$header = array(
|
154
|
-
|
155
|
-
'X-Quoine-API-Version:' . $version,
|
156
|
-
|
157
|
-
'X-Quoine-Auth:' . $sign,
|
158
|
-
|
159
|
-
'Content-Type:application/json',
|
160
|
-
|
161
|
-
//'Content-Length:'. strlen($body),
|
162
|
-
|
163
|
-
);
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
//確認用
|
168
|
-
|
169
|
-
print_r($header);
|
170
|
-
|
171
|
-
$context = stream_context_create(array(
|
172
|
-
|
173
|
-
'http' => array(
|
174
|
-
|
175
|
-
'method' => $method,
|
176
|
-
|
177
|
-
'header' => implode(PHP_EOL, $header),
|
178
|
-
|
179
|
-
// 'content' => $body,
|
180
|
-
|
181
|
-
)
|
182
|
-
|
183
|
-
));
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
// API呼び出し
|
188
|
-
|
189
|
-
$response = file_get_contents($url, false, $context);
|
190
|
-
|
191
|
-
$result = json_decode($response, true);
|
192
|
-
|
193
|
-
print_r($result);
|
194
|
-
|
195
|
-
```
|
1
error内容変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,6 +11,14 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
サンプルソースがRubyでPHPで使用したいので自分なりに変更してみましたがうまくいかないのでご協力をお願いします。
|
14
|
+
|
15
|
+
```php
|
16
|
+
|
17
|
+
error内容
|
18
|
+
|
19
|
+
Fatal error: Uncaught exception 'DomainException' with message 'Algorithm not supported' in /home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php on line 191 DomainException: Algorithm not supported in /home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php on line 191 Call Stack: 0.0015 236392 1. {main}() /home/ubuntu/workspace/quoinex_balance.php:0 0.0143 270496 2. Firebase\JWT\JWT::encode() /home/ubuntu/workspace/quoinex_balance.php:31 0.0144 272128 3. Firebase\JWT\JWT::sign() /home/ubuntu/workspace/vendor/firebase/php-jwt/src/JWT.php:170
|
20
|
+
|
21
|
+
```
|
14
22
|
|
15
23
|
|
16
24
|
|