|
|
@@ -35,7 +35,7 @@ class WithdrawService
|
|
|
$data = [
|
|
|
'user_name' => self::$user_name,
|
|
|
'password' => self::$password,
|
|
|
- 'timestamp' => (string)time(),
|
|
|
+ 'timestamp' => time(),
|
|
|
];
|
|
|
ksort($data);
|
|
|
var_dump($data);
|
|
|
@@ -48,7 +48,7 @@ class WithdrawService
|
|
|
echo "\n";
|
|
|
$data['sign'] = $sign;
|
|
|
var_dump($data);
|
|
|
- $res = json_decode(HttpService::postRequest(self::$url . '/sdk/v1/login', $data, ['content-type:application/json']), true);
|
|
|
+ $res = json_decode(self::do_request(self::$url . '/sdk/v1/login', $data, ['content-type:application/json'], true, true), true);
|
|
|
var_dump($res);
|
|
|
}
|
|
|
|
|
|
@@ -57,6 +57,36 @@ class WithdrawService
|
|
|
{
|
|
|
$url = self::$url . $url;
|
|
|
$data = ['token' => self::$token, 'data' => $data];
|
|
|
- return json_decode(HttpService::postRequest($url, $data, ['content-type:application/json']), true);
|
|
|
+ return json_decode(self::do_request(self::$url . $url, $data, ['content-type:application/json'], true, true), true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ protected static function do_request($url, $data, $header = null, $post = true, $json = false, $format = 0, $form = false)
|
|
|
+ {
|
|
|
+ $curl = curl_init();
|
|
|
+ curl_setopt($curl, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+ if ($post) {
|
|
|
+ curl_setopt($curl, CURLOPT_POST, 1);
|
|
|
+ if (!$json && !$form) {
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
|
|
+ } else if ($json && !$form) {
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data, $format));
|
|
|
+ } else {
|
|
|
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ if ($header) {
|
|
|
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
|
|
|
+ curl_setopt($curl, CURLOPT_HEADER, 0);
|
|
|
+ }
|
|
|
+ $result = curl_exec($curl);
|
|
|
+ if (curl_errno($curl)) {
|
|
|
+ return json_encode(['status' => curl_errno($curl), 'msg' => '请求失败']);
|
|
|
+ }
|
|
|
+ curl_close($curl);
|
|
|
+ return $result;
|
|
|
}
|
|
|
}
|