@@ -3,37 +3,37 @@ |
||
3 | 3 | |
4 | 4 | class UpdateLocation extends AbstractRequest { |
5 | 5 | /** |
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - /** |
|
10 | - * @return Location |
|
11 | - */ |
|
12 | - public function getLocation() |
|
13 | - { |
|
14 | - return $this->location; |
|
15 | - } |
|
16 | - /** |
|
17 | - * @param Location $location |
|
18 | - */ |
|
19 | - public function setLocation($location) |
|
20 | - { |
|
21 | - $this->location = $location; |
|
22 | - } |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + /** |
|
10 | + * @return Location |
|
11 | + */ |
|
12 | + public function getLocation() |
|
13 | + { |
|
14 | + return $this->location; |
|
15 | + } |
|
16 | + /** |
|
17 | + * @param Location $location |
|
18 | + */ |
|
19 | + public function setLocation($location) |
|
20 | + { |
|
21 | + $this->location = $location; |
|
22 | + } |
|
23 | 23 | |
24 | - function getApiEndPoint() |
|
25 | - { |
|
26 | - return '/v2/users/location'; |
|
27 | - } |
|
28 | - function getPayload() |
|
29 | - { |
|
30 | - return array( |
|
24 | + function getApiEndPoint() |
|
25 | + { |
|
26 | + return '/v2/users/location'; |
|
27 | + } |
|
28 | + function getPayload() |
|
29 | + { |
|
30 | + return array( |
|
31 | 31 | 'location' => $this->getLocation()->toArray(), |
32 | - ); |
|
33 | - } |
|
34 | - function getMethod() |
|
35 | - { |
|
36 | - return 'PUT'; |
|
37 | - } |
|
32 | + ); |
|
33 | + } |
|
34 | + function getMethod() |
|
35 | + { |
|
36 | + return 'PUT'; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | class GetCaptcha extends AbstractRequest |
3 | 3 | { |
4 | - function getApiEndPoint() |
|
5 | - { |
|
6 | - return '/v3/user/verification/imageCaptcha/'; |
|
7 | - } |
|
8 | - function getPayload() |
|
9 | - { |
|
10 | - return array( |
|
11 | - ); |
|
12 | - } |
|
13 | - function getMethod() |
|
14 | - { |
|
15 | - return 'GET'; |
|
16 | - } |
|
4 | + function getApiEndPoint() |
|
5 | + { |
|
6 | + return '/v3/user/verification/imageCaptcha/'; |
|
7 | + } |
|
8 | + function getPayload() |
|
9 | + { |
|
10 | + return array( |
|
11 | + ); |
|
12 | + } |
|
13 | + function getMethod() |
|
14 | + { |
|
15 | + return 'GET'; |
|
16 | + } |
|
17 | 17 | } |
18 | 18 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | class Jodel |
4 | 4 | { |
5 | - public $jodel; |
|
5 | + public $jodel; |
|
6 | 6 | |
7 | 7 | |
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -3,18 +3,18 @@ |
||
3 | 3 | |
4 | 4 | class GetPostDetails extends AbstractRequest { |
5 | 5 | |
6 | - function getApiEndPoint() |
|
7 | - { |
|
8 | - return '/v2/posts/' . $_GET['postId']; |
|
9 | - } |
|
10 | - function getPayload() |
|
11 | - { |
|
12 | - return array( |
|
13 | - ); |
|
14 | - } |
|
15 | - function getMethod() |
|
16 | - { |
|
17 | - return 'GET'; |
|
18 | - } |
|
6 | + function getApiEndPoint() |
|
7 | + { |
|
8 | + return '/v2/posts/' . $_GET['postId']; |
|
9 | + } |
|
10 | + function getPayload() |
|
11 | + { |
|
12 | + return array( |
|
13 | + ); |
|
14 | + } |
|
15 | + function getMethod() |
|
16 | + { |
|
17 | + return 'GET'; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 |
@@ -2,41 +2,41 @@ |
||
2 | 2 | |
3 | 3 | class GetChannel extends AbstractRequest |
4 | 4 | { |
5 | - /** |
|
6 | - * @var Location |
|
7 | - */ |
|
8 | - public $location; |
|
9 | - public $channel; |
|
10 | - public $hasPayload = FALSE; |
|
11 | - public $lastPostId = ''; |
|
12 | - public $view = 'combo'; |
|
5 | + /** |
|
6 | + * @var Location |
|
7 | + */ |
|
8 | + public $location; |
|
9 | + public $channel; |
|
10 | + public $hasPayload = FALSE; |
|
11 | + public $lastPostId = ''; |
|
12 | + public $view = 'combo'; |
|
13 | 13 | |
14 | - function getApiEndPoint() |
|
15 | - { |
|
16 | - if($this->lastPostId == '') |
|
17 | - { |
|
18 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | - } |
|
20 | - else |
|
21 | - { |
|
22 | - if($this->view == 'combo') |
|
23 | - { |
|
24 | - $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | - } |
|
26 | - else |
|
27 | - { |
|
28 | - $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | - } |
|
30 | - } |
|
31 | - return $apiEndPoint; |
|
32 | - } |
|
33 | - function getPayload() |
|
34 | - { |
|
35 | - return array( |
|
36 | - ); |
|
37 | - } |
|
38 | - function getMethod() |
|
39 | - { |
|
40 | - return 'GET'; |
|
41 | - } |
|
14 | + function getApiEndPoint() |
|
15 | + { |
|
16 | + if($this->lastPostId == '') |
|
17 | + { |
|
18 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel; |
|
19 | + } |
|
20 | + else |
|
21 | + { |
|
22 | + if($this->view == 'combo') |
|
23 | + { |
|
24 | + $apiEndPoint = '/v3/posts/hashtag?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
25 | + } |
|
26 | + else |
|
27 | + { |
|
28 | + $apiEndPoint = '/v3/posts/hashtag/' . $this->view . '?hashtag=' . $this->channel . '&after=' . $this->lastPostId; |
|
29 | + } |
|
30 | + } |
|
31 | + return $apiEndPoint; |
|
32 | + } |
|
33 | + function getPayload() |
|
34 | + { |
|
35 | + return array( |
|
36 | + ); |
|
37 | + } |
|
38 | + function getMethod() |
|
39 | + { |
|
40 | + return 'GET'; |
|
41 | + } |
|
42 | 42 | } |
@@ -129,7 +129,7 @@ |
||
129 | 129 | <?php |
130 | 130 | if(is_file(realpath(__DIR__ . '/..') . '/piwik-script.html')) |
131 | 131 | { |
132 | - include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
132 | + include(realpath(__DIR__ . '/..') . '/piwik-script.html'); |
|
133 | 133 | } |
134 | 134 | ?> |
135 | 135 |
@@ -13,17 +13,17 @@ |
||
13 | 13 | public $varsToDump; |
14 | 14 | |
15 | 15 | function __construct($msg = 'not Set', $varsToDump = 'not Set', $view = 'not Set', $actions = 'not Set', $accountId = 'not Set', $isVerified = 'not Set', $isTokenFresh = 'not Set', $page = 'not Set', $referrer = 'not Set') |
16 | - { |
|
17 | - $this->view = $view; |
|
18 | - $this->actions = $actions; |
|
19 | - $this->accountId = $accountId; |
|
20 | - $this->isVerified = $isVerified; |
|
21 | - $this->isTokenFresh = $isTokenFresh; |
|
22 | - $this->page = $page; |
|
23 | - $this->referrer = $referrer; |
|
24 | - $this->msg = $msg; |
|
25 | - $this->varsToDump = $varsToDump; |
|
26 | - } |
|
16 | + { |
|
17 | + $this->view = $view; |
|
18 | + $this->actions = $actions; |
|
19 | + $this->accountId = $accountId; |
|
20 | + $this->isVerified = $isVerified; |
|
21 | + $this->isTokenFresh = $isTokenFresh; |
|
22 | + $this->page = $page; |
|
23 | + $this->referrer = $referrer; |
|
24 | + $this->msg = $msg; |
|
25 | + $this->varsToDump = $varsToDump; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | function writeErrorToLog() |
29 | 29 | { |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | |
49 | 49 | function user_log($msg) |
50 | 50 | { |
51 | - $log = $msg . PHP_EOL; |
|
52 | - file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
51 | + $log = $msg . PHP_EOL; |
|
52 | + file_put_contents(realpath(__DIR__ . '/..') . '/logs/user_log-' . date("j.n.Y") . '.txt', $log, FILE_APPEND); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | function isUserBot() |
56 | 56 | { |
57 | - preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
57 | + preg_match('/bot|spider|google|twitter/i', $_SERVER['HTTP_USER_AGENT'], $matches); |
|
58 | 58 | |
59 | - return (isset($matches[0])) ? true : false; |
|
59 | + return (isset($matches[0])) ? true : false; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | function configPropertyExists($config, $property) |
63 | 63 | { |
64 | - if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | - { |
|
66 | - return FALSE; |
|
67 | - } |
|
68 | - else |
|
69 | - { |
|
70 | - return TRUE; |
|
71 | - } |
|
64 | + if(!array_key_exists($property, $config) || !isset($config[$property]) || $config[$property] == '' || $config[$property] == 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') |
|
65 | + { |
|
66 | + return FALSE; |
|
67 | + } |
|
68 | + else |
|
69 | + { |
|
70 | + return TRUE; |
|
71 | + } |
|
72 | 72 | } |
73 | 73 | function isUserAdmin() { |
74 | 74 | global $config; |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | |
85 | 85 | function isDeviceUidInDatabase($deviceUid) |
86 | 86 | { |
87 | - $db = new DatabaseConnect(); |
|
88 | - $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
87 | + $db = new DatabaseConnect(); |
|
88 | + $result = $db->query("SELECT * FROM accounts WHERE device_uid='" . $deviceUid . "'"); |
|
89 | 89 | |
90 | - if ($result->num_rows > 0) |
|
91 | - { |
|
92 | - return TRUE; |
|
93 | - } |
|
94 | - else |
|
95 | - { |
|
96 | - return FALSE; |
|
97 | - } |
|
90 | + if ($result->num_rows > 0) |
|
91 | + { |
|
92 | + return TRUE; |
|
93 | + } |
|
94 | + else |
|
95 | + { |
|
96 | + return FALSE; |
|
97 | + } |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //Check if it's a Spider or Google Bot |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | if(configPropertyExists($config, 'karmaDeviceUid')) |
124 | - { |
|
125 | - $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - error_log("No Karma deviceUid set in config file"); |
|
124 | + { |
|
125 | + $jodelAccountForKarma = new JodelAccount($config['karmaDeviceUid']); |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + error_log("No Karma deviceUid set in config file"); |
|
130 | 130 | $jodelAccountForKarma = new JodelAccount($deviceUid); |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | /* |
134 | 134 | * Cunstruct View |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | { |
242 | 242 | $jodelAccountForKarma->votePostId($_GET['postId'], $_GET['vote']); |
243 | 243 | if(isset($_GET['getPostDetails']) && isset($_GET['getPostDetails'])) |
244 | - { |
|
245 | - header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
246 | - } |
|
247 | - else |
|
248 | - { |
|
249 | - header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
250 | - } |
|
251 | - die(); |
|
244 | + { |
|
245 | + header('Location: index.php?getPostDetails=true&postId=' . htmlspecialchars($_GET['postId_parent']) . '#postId-' . htmlspecialchars($_GET['postId'])); |
|
246 | + } |
|
247 | + else |
|
248 | + { |
|
249 | + header("Location: index.php#postId-" . htmlspecialchars($_GET['postId'])); |
|
250 | + } |
|
251 | + die(); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | //SendJodel |
@@ -2,20 +2,20 @@ discard block |
||
2 | 2 | |
3 | 3 | abstract class AbstractRequest |
4 | 4 | { |
5 | - const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | - const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | - const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu'; |
|
8 | - const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | - const CLIENT_TYPE = 'android_4.34.2'; |
|
5 | + const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26'; |
|
6 | + const APIURL = 'https://api.go-tellm.com/api'; |
|
7 | + const SECRET = 'SDydTnTdqqaiAMfneLkqXYxamvNuUYOmkqpdiZTu'; |
|
8 | + const USERAGENT = 'Jodel/4.34.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )'; |
|
9 | + const CLIENT_TYPE = 'android_4.34.2'; |
|
10 | 10 | |
11 | - private $accessToken = null; |
|
12 | - private $payLoad; |
|
13 | - public $expects = ''; |
|
14 | - public $version = 'v2'; |
|
15 | - public $hasPayload = FALSE; |
|
11 | + private $accessToken = null; |
|
12 | + private $payLoad; |
|
13 | + public $expects = ''; |
|
14 | + public $version = 'v2'; |
|
15 | + public $hasPayload = FALSE; |
|
16 | 16 | |
17 | - public function execute() |
|
18 | - { |
|
17 | + public function execute() |
|
18 | + { |
|
19 | 19 | $result = new \stdClass(); |
20 | 20 | |
21 | 21 | $this->payLoad = $this->getPayload(); |
@@ -25,16 +25,16 @@ discard block |
||
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | - $this->payLoad = json_encode($this->payLoad); |
|
29 | - $header = $this->getSignHeaders(); |
|
30 | - $url = $this->getFullUrl(); |
|
28 | + $this->payLoad = json_encode($this->payLoad); |
|
29 | + $header = $this->getSignHeaders(); |
|
30 | + $url = $this->getFullUrl(); |
|
31 | 31 | |
32 | - if ($this->getAccessToken()) { |
|
33 | - $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | - } |
|
35 | - //Comment out to debug the Request: |
|
32 | + if ($this->getAccessToken()) { |
|
33 | + $header['Authorization'] = "Bearer " . $this->getAccessToken(); |
|
34 | + } |
|
35 | + //Comment out to debug the Request: |
|
36 | 36 | |
37 | - /* |
|
37 | + /* |
|
38 | 38 | printf("URL: "); |
39 | 39 | var_dump($url); |
40 | 40 | echo "<br />"; |
@@ -45,95 +45,95 @@ discard block |
||
45 | 45 | var_dump($this->payLoad); |
46 | 46 | echo "<br />"; |
47 | 47 | */ |
48 | - /* |
|
48 | + /* |
|
49 | 49 | $options = array( |
50 | 50 | 'timeout' => 100, |
51 | 51 | 'connect_timeout' => 100, |
52 | 52 | 'proxy' => '186.103.169.165:8080', |
53 | 53 | );*/ |
54 | 54 | |
55 | - switch ($this->getMethod()) { |
|
56 | - case 'POST': |
|
57 | - $result = Requests::post($url, $header, $this->payLoad); |
|
58 | - break; |
|
59 | - case 'GET': |
|
60 | - if($this->hasPayload) |
|
61 | - { |
|
62 | - $result = Requests::get($url, $header, $this->payLoad); |
|
63 | - } |
|
64 | - else |
|
65 | - { |
|
66 | - $result = Requests::get($url, $header); |
|
67 | - } |
|
68 | - break; |
|
69 | - case 'PUT': |
|
70 | - $result = Requests::put($url, $header, $this->payLoad); |
|
71 | - break; |
|
72 | - } |
|
73 | - switch ($result->status_code) { |
|
74 | - case 200: |
|
75 | - $result = json_decode($result->body, true); |
|
76 | - break; |
|
77 | - case 204: |
|
78 | - $result = 'Success'; |
|
79 | - break; |
|
80 | - case 400: |
|
81 | - $result = json_decode($result->body, true); |
|
82 | - error_log('Error 400 - ' . print_r($result, true)); |
|
83 | - break; |
|
84 | - case 401: |
|
85 | - $result = json_decode($result->body, true); |
|
86 | - error_log('Error 401 - ' . print_r($result, true)); |
|
87 | - break; |
|
88 | - case 404: |
|
89 | - error_log('Error 404 - ' . print_r($result, true)); |
|
90 | - $result = json_decode($result->body, true); |
|
91 | - break; |
|
55 | + switch ($this->getMethod()) { |
|
56 | + case 'POST': |
|
57 | + $result = Requests::post($url, $header, $this->payLoad); |
|
58 | + break; |
|
59 | + case 'GET': |
|
60 | + if($this->hasPayload) |
|
61 | + { |
|
62 | + $result = Requests::get($url, $header, $this->payLoad); |
|
63 | + } |
|
64 | + else |
|
65 | + { |
|
66 | + $result = Requests::get($url, $header); |
|
67 | + } |
|
68 | + break; |
|
69 | + case 'PUT': |
|
70 | + $result = Requests::put($url, $header, $this->payLoad); |
|
71 | + break; |
|
72 | + } |
|
73 | + switch ($result->status_code) { |
|
74 | + case 200: |
|
75 | + $result = json_decode($result->body, true); |
|
76 | + break; |
|
77 | + case 204: |
|
78 | + $result = 'Success'; |
|
79 | + break; |
|
80 | + case 400: |
|
81 | + $result = json_decode($result->body, true); |
|
82 | + error_log('Error 400 - ' . print_r($result, true)); |
|
83 | + break; |
|
84 | + case 401: |
|
85 | + $result = json_decode($result->body, true); |
|
86 | + error_log('Error 401 - ' . print_r($result, true)); |
|
87 | + break; |
|
88 | + case 404: |
|
89 | + error_log('Error 404 - ' . print_r($result, true)); |
|
90 | + $result = json_decode($result->body, true); |
|
91 | + break; |
|
92 | 92 | case 477: |
93 | - $result = json_decode($result->body, true); |
|
94 | - error_log('Error 477 - ' . print_r($result, true)); |
|
95 | - break; |
|
96 | - case 429: |
|
97 | - error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
98 | - exit("Error 429: Too Many Requests"); |
|
99 | - break; |
|
100 | - case 403: |
|
101 | - error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
102 | - $result = json_decode($result->body, true); |
|
103 | - break; |
|
104 | - case 503: |
|
105 | - error_log('Error 503 - ' . print_r($result, true)); |
|
106 | - $result = json_decode($result->body, true); |
|
93 | + $result = json_decode($result->body, true); |
|
94 | + error_log('Error 477 - ' . print_r($result, true)); |
|
95 | + break; |
|
96 | + case 429: |
|
97 | + error_log('Error 429 - Too Many Requests' . print_r(json_decode($result->body, true), true)); |
|
98 | + exit("Error 429: Too Many Requests"); |
|
99 | + break; |
|
100 | + case 403: |
|
101 | + error_log('Error 403 - Access denied:' . print_r(json_decode($result->body, true), true)); |
|
102 | + $result = json_decode($result->body, true); |
|
103 | + break; |
|
104 | + case 503: |
|
105 | + error_log('Error 503 - ' . print_r($result, true)); |
|
106 | + $result = json_decode($result->body, true); |
|
107 | 107 | |
108 | - if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
|
109 | - { |
|
110 | - header('location:'.$_SERVER['PHP_SELF']); |
|
111 | - } |
|
112 | - break; |
|
113 | - default: |
|
114 | - error_log('Error '.$result->status_code.' - Unauthorized'); |
|
115 | - $result = json_decode($result->body, true); |
|
116 | - } |
|
108 | + if(array_key_exists('error', $result) && $result['error'] == 'Service Unavailable"') |
|
109 | + { |
|
110 | + header('location:'.$_SERVER['PHP_SELF']); |
|
111 | + } |
|
112 | + break; |
|
113 | + default: |
|
114 | + error_log('Error '.$result->status_code.' - Unauthorized'); |
|
115 | + $result = json_decode($result->body, true); |
|
116 | + } |
|
117 | 117 | |
118 | - //important for account refresh |
|
119 | - if($device_uid != '') |
|
120 | - { |
|
118 | + //important for account refresh |
|
119 | + if($device_uid != '') |
|
120 | + { |
|
121 | 121 | $result[0] = $result; |
122 | 122 | $result[1] = $device_uid; |
123 | - } |
|
123 | + } |
|
124 | 124 | |
125 | 125 | |
126 | - /* var_dump($result); */ |
|
126 | + /* var_dump($result); */ |
|
127 | 127 | |
128 | - return $result; |
|
129 | - } |
|
130 | - abstract function getPayload(); |
|
131 | - /** |
|
132 | - * Gets Sign headers |
|
133 | - * @return array headers |
|
134 | - */ |
|
135 | - private function getSignHeaders() |
|
136 | - { |
|
128 | + return $result; |
|
129 | + } |
|
130 | + abstract function getPayload(); |
|
131 | + /** |
|
132 | + * Gets Sign headers |
|
133 | + * @return array headers |
|
134 | + */ |
|
135 | + private function getSignHeaders() |
|
136 | + { |
|
137 | 137 | if($this->getAccessToken() == null) { |
138 | 138 | $payload_accessToken = ""; |
139 | 139 | } |
@@ -142,54 +142,54 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | - $headers = array( |
|
146 | - "Connection" => "keep-alive", |
|
147 | - "Accept-Encoding" => "gzip", |
|
148 | - "Content-Type" => "application/json; charset=UTF-8", |
|
149 | - "User-Agent" => self::USERAGENT |
|
150 | - ); |
|
151 | - $timestamp = new DateTime(); |
|
152 | - $timestamp = $timestamp->format(DateTime::ATOM); |
|
153 | - $timestamp = substr($timestamp, 0, -6); |
|
154 | - $timestamp .= "Z"; |
|
155 | - $urlParts = parse_url($this->getFullUrl()); |
|
156 | - $url2 = ""; |
|
157 | - $req = [$this->getMethod(), |
|
158 | - $urlParts['host'], |
|
159 | - "443", |
|
160 | - $urlParts['path'], |
|
161 | - $payload_accessToken, |
|
162 | - $timestamp, |
|
163 | - $url2, |
|
164 | - $this->payLoad]; |
|
165 | - $reqString = implode("%", $req); |
|
166 | - $secret = self::SECRET; |
|
167 | - $signature = hash_hmac('sha1', $reqString, $secret); |
|
168 | - $signature = strtoupper($signature); |
|
169 | - $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
170 | - $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
171 | - $headers['X-Timestamp'] = $timestamp; |
|
172 | - $headers['X-Api-Version'] = '0.2'; |
|
173 | - return $headers; |
|
174 | - } |
|
175 | - private function getFullUrl() |
|
176 | - { |
|
177 | - return self::APIURL . $this->getApiEndPoint(); |
|
178 | - } |
|
179 | - abstract function getApiEndPoint(); |
|
180 | - abstract function getMethod(); |
|
181 | - /** |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - private function getAccessToken() |
|
185 | - { |
|
186 | - return $this->accessToken; |
|
187 | - } |
|
188 | - /** |
|
189 | - * @param string $accessToken |
|
190 | - */ |
|
191 | - public function setAccessToken($accessToken) |
|
192 | - { |
|
193 | - $this->accessToken = $accessToken; |
|
194 | - } |
|
145 | + $headers = array( |
|
146 | + "Connection" => "keep-alive", |
|
147 | + "Accept-Encoding" => "gzip", |
|
148 | + "Content-Type" => "application/json; charset=UTF-8", |
|
149 | + "User-Agent" => self::USERAGENT |
|
150 | + ); |
|
151 | + $timestamp = new DateTime(); |
|
152 | + $timestamp = $timestamp->format(DateTime::ATOM); |
|
153 | + $timestamp = substr($timestamp, 0, -6); |
|
154 | + $timestamp .= "Z"; |
|
155 | + $urlParts = parse_url($this->getFullUrl()); |
|
156 | + $url2 = ""; |
|
157 | + $req = [$this->getMethod(), |
|
158 | + $urlParts['host'], |
|
159 | + "443", |
|
160 | + $urlParts['path'], |
|
161 | + $payload_accessToken, |
|
162 | + $timestamp, |
|
163 | + $url2, |
|
164 | + $this->payLoad]; |
|
165 | + $reqString = implode("%", $req); |
|
166 | + $secret = self::SECRET; |
|
167 | + $signature = hash_hmac('sha1', $reqString, $secret); |
|
168 | + $signature = strtoupper($signature); |
|
169 | + $headers['X-Authorization'] = 'HMAC ' . $signature; |
|
170 | + $headers['X-Client-Type'] = self::CLIENT_TYPE; |
|
171 | + $headers['X-Timestamp'] = $timestamp; |
|
172 | + $headers['X-Api-Version'] = '0.2'; |
|
173 | + return $headers; |
|
174 | + } |
|
175 | + private function getFullUrl() |
|
176 | + { |
|
177 | + return self::APIURL . $this->getApiEndPoint(); |
|
178 | + } |
|
179 | + abstract function getApiEndPoint(); |
|
180 | + abstract function getMethod(); |
|
181 | + /** |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + private function getAccessToken() |
|
185 | + { |
|
186 | + return $this->accessToken; |
|
187 | + } |
|
188 | + /** |
|
189 | + * @param string $accessToken |
|
190 | + */ |
|
191 | + public function setAccessToken($accessToken) |
|
192 | + { |
|
193 | + $this->accessToken = $accessToken; |
|
194 | + } |
|
195 | 195 | } |