Completed
Push — master ( ae0f54...3a96c8 )
by mains
02:54
created
php/Requests/PostCaptcha.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,22 +2,22 @@
 block discarded – undo
2 2
 class PostCaptcha extends AbstractRequest
3 3
 {
4 4
 	public $captchaKey;
5
-    public $captchaSolution;
5
+	public $captchaSolution;
6 6
 
7
-    function getApiEndPoint()
8
-    {
9
-        return '/v3/user/verification/imageCaptcha/';
10
-    }
11
-    function getPayload()
12
-    {
13
-        return array(
14
-            'key' => $this->captchaKey,
15
-            'answer' => $this->captchaSolution,
16
-        );
17
-    }
18
-    function getMethod()
19
-    {
20
-        return 'POST';
21
-    }
7
+	function getApiEndPoint()
8
+	{
9
+		return '/v3/user/verification/imageCaptcha/';
10
+	}
11
+	function getPayload()
12
+	{
13
+		return array(
14
+			'key' => $this->captchaKey,
15
+			'answer' => $this->captchaSolution,
16
+		);
17
+	}
18
+	function getMethod()
19
+	{
20
+		return 'POST';
21
+	}
22 22
 }
23 23
 
Please login to merge, or discard this patch.
php/Requests/GetUserConfig.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,18 +2,18 @@
 block discarded – undo
2 2
 class GetUserConfig extends AbstractRequest
3 3
 {
4 4
 		
5
-    function getApiEndPoint()
6
-    {
7
-        return '/v3/user/config/';
8
-    }
9
-    function getPayload()
10
-    {
11
-        return array(
12
-        );
13
-    }
14
-    function getMethod()
15
-    {
16
-        return 'GET';
17
-    }
5
+	function getApiEndPoint()
6
+	{
7
+		return '/v3/user/config/';
8
+	}
9
+	function getPayload()
10
+	{
11
+		return array(
12
+		);
13
+	}
14
+	function getMethod()
15
+	{
16
+		return 'GET';
17
+	}
18 18
 }
19 19
 
Please login to merge, or discard this patch.
php/Requests/UpdateLocation.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -3,37 +3,37 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
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 = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
-    const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.32.2';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'OFIqFvBgkccPNTVbIzkYaSmrwMlbVzRoOBBjXUIG';
8
+	const USERAGENT = 'Jodel/4.32.2 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.32.2';
10 10
     
11
-    private $accessToken = null;
12
-    private $payLoad;
13
-    public $expects = '';
14
-    public $version = 'v2';
11
+	private $accessToken = null;
12
+	private $payLoad;
13
+	public $expects = '';
14
+	public $version = 'v2';
15 15
 
16
-    public function execute()
17
-    {
16
+	public function execute()
17
+	{
18 18
 		$result = new \stdClass();
19 19
 		        
20 20
 		$this->payLoad = $this->getPayload();
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 		}
25 25
 				
26 26
 				
27
-        $this->payLoad = json_encode($this->payLoad);
28
-        $header = $this->getSignHeaders();
29
-        $url = $this->getFullUrl();
27
+		$this->payLoad = json_encode($this->payLoad);
28
+		$header = $this->getSignHeaders();
29
+		$url = $this->getFullUrl();
30 30
 
31
-        if ($this->getAccessToken()) {
32
-            $header['Authorization'] = "Bearer " . $this->getAccessToken();
33
-        }
34
-        //Comment out to debug the Request:
31
+		if ($this->getAccessToken()) {
32
+			$header['Authorization'] = "Bearer " . $this->getAccessToken();
33
+		}
34
+		//Comment out to debug the Request:
35 35
 
36
-        /*
36
+		/*
37 37
         printf("URL: ");
38 38
         var_dump($url);
39 39
         echo "<br />";
@@ -44,82 +44,82 @@  discard block
 block discarded – undo
44 44
         var_dump($this->payLoad);
45 45
         echo "<br />";
46 46
         */
47
-        /*
47
+		/*
48 48
         $options = array(
49 49
             'timeout' => 100,
50 50
             'connect_timeout' => 100,
51 51
             'proxy' => '186.103.169.165:8080',
52 52
         );*/
53 53
 
54
-        switch ($this->getMethod()) {
55
-            case 'POST':
56
-                $result = Requests::post($url, $header, $this->payLoad);
57
-                break;
58
-            case 'GET':
59
-                if($this->version == 'v3')
60
-                {
61
-                    $result = Requests::get($url, $header);
62
-                }
63
-                else
64
-                {
65
-                    $result = Requests::get($url, $header);
66
-                }
67
-                break;
68
-            case 'PUT':
69
-                $result = Requests::put($url, $header, $this->payLoad);
70
-                break;
71
-        }
72
-        switch ($result->status_code) {
73
-            case 200:
74
-                $result = json_decode($result->body, true);
75
-                break;
76
-            case 204:
77
-                $result = "Success";
78
-                break;
79
-            case 401:
54
+		switch ($this->getMethod()) {
55
+			case 'POST':
56
+				$result = Requests::post($url, $header, $this->payLoad);
57
+				break;
58
+			case 'GET':
59
+				if($this->version == 'v3')
60
+				{
61
+					$result = Requests::get($url, $header);
62
+				}
63
+				else
64
+				{
65
+					$result = Requests::get($url, $header);
66
+				}
67
+				break;
68
+			case 'PUT':
69
+				$result = Requests::put($url, $header, $this->payLoad);
70
+				break;
71
+		}
72
+		switch ($result->status_code) {
73
+			case 200:
74
+				$result = json_decode($result->body, true);
75
+				break;
76
+			case 204:
77
+				$result = "Success";
78
+				break;
79
+			case 401:
80 80
 				//throw new \Exception('Unauthorized');
81
-                error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
82
-                break;
83
-            case 404:
84
-                //echo "Es wurde bereits gevoted";
85
-                error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
81
+				error_log('Error 401 - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
82
+				break;
83
+			case 404:
84
+				//echo "Es wurde bereits gevoted";
85
+				error_log('Error 404 - Es wurde bereits gevoted'); // - JodelDeviceId:' . $deviceUid);
86 86
 			case 477:
87
-                //echo "Es wurde bereits gevoted";
88
-                //throw  new \Exception('Signing failed!');
89
-                error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
90
-                break;
91
-            case 429:
92
-                error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
93
-            	exit("Error 429: Too Many Requests");
94
-            	break;
95
-            case 403:
96
-                error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
97
-                exit("Error 403: Access denied");
98
-                break;
99
-            default:
100
-                error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
101
-                //throw  new \Exception('Unknown Error: '.$result->status_code);
102
-        }
87
+				//echo "Es wurde bereits gevoted";
88
+				//throw  new \Exception('Signing failed!');
89
+				error_log('Error 477 - Signing failed'); // - JodelDeviceId:' . $deviceUid);
90
+				break;
91
+			case 429:
92
+				error_log('Error 429 - Too Many Requests'); // - JodelDeviceId:' . $deviceUid);
93
+				exit("Error 429: Too Many Requests");
94
+				break;
95
+			case 403:
96
+				error_log('Error 403 - Access denied'); // - JodelDeviceId:' . $deviceUid);
97
+				exit("Error 403: Access denied");
98
+				break;
99
+			default:
100
+				error_log('Error '.$result->status_code.' - Unauthorized'); // - JodelDeviceId:' . $deviceUid);
101
+				//throw  new \Exception('Unknown Error: '.$result->status_code);
102
+		}
103 103
 
104
-        if($device_uid != '')
105
-        {
104
+		if($device_uid != '')
105
+		{
106 106
 			$result[0] = $result;
107 107
 			$result[1] = $device_uid;
108 108
 	}
109 109
 
110
-        /*
110
+		/*
111 111
         var_dump($result);
112 112
         */
113 113
 
114
-        return $result;
115
-    }
116
-    abstract function getPayload();
117
-    /**
118
-     * Gets Sign headers
119
-     * @return array headers
120
-     */
121
-    private function getSignHeaders()
122
-    {
114
+		return $result;
115
+	}
116
+	abstract function getPayload();
117
+	/**
118
+	 * Gets Sign headers
119
+	 * @return array headers
120
+	 */
121
+	private function getSignHeaders()
122
+	{
123 123
 			if($this->getAccessToken() == null) {
124 124
 				$payload_accessToken = "";
125 125
 			}
@@ -128,54 +128,54 @@  discard block
 block discarded – undo
128 128
 			}
129 129
 			
130 130
 			
131
-        $headers = array(
132
-            "Connection" => "keep-alive",
133
-            "Accept-Encoding" => "gzip",
134
-            "Content-Type" => "application/json; charset=UTF-8",
135
-            "User-Agent" => self::USERAGENT
136
-        );
137
-        $timestamp = new DateTime();
138
-        $timestamp = $timestamp->format(DateTime::ATOM);
139
-        $timestamp = substr($timestamp, 0, -6);
140
-        $timestamp .= "Z";
141
-        $urlParts = parse_url($this->getFullUrl());
142
-        $url2 = "";
143
-        $req = [$this->getMethod(),
144
-            $urlParts['host'],
145
-            "443",
146
-            $urlParts['path'],
147
-            $payload_accessToken,
148
-            $timestamp,
149
-            $url2,
150
-            $this->payLoad];
151
-        $reqString = implode("%", $req);
152
-        $secret = self::SECRET;
153
-        $signature = hash_hmac('sha1', $reqString, $secret);
154
-        $signature = strtoupper($signature);
155
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
156
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
157
-        $headers['X-Timestamp'] = $timestamp;
158
-        $headers['X-Api-Version'] = '0.2';
159
-        return $headers;
160
-    }
161
-    private function getFullUrl()
162
-    {
163
-        return self::APIURL . $this->getApiEndPoint();
164
-    }
165
-    abstract function getApiEndPoint();
166
-    abstract function getMethod();
167
-    /**
168
-     * @return string
169
-     */
170
-    private function getAccessToken()
171
-    {
172
-        return $this->accessToken;
173
-    }
174
-    /**
175
-     * @param string $accessToken
176
-     */
177
-    public function setAccessToken($accessToken)
178
-    {
179
-        $this->accessToken = $accessToken;
180
-    }
131
+		$headers = array(
132
+			"Connection" => "keep-alive",
133
+			"Accept-Encoding" => "gzip",
134
+			"Content-Type" => "application/json; charset=UTF-8",
135
+			"User-Agent" => self::USERAGENT
136
+		);
137
+		$timestamp = new DateTime();
138
+		$timestamp = $timestamp->format(DateTime::ATOM);
139
+		$timestamp = substr($timestamp, 0, -6);
140
+		$timestamp .= "Z";
141
+		$urlParts = parse_url($this->getFullUrl());
142
+		$url2 = "";
143
+		$req = [$this->getMethod(),
144
+			$urlParts['host'],
145
+			"443",
146
+			$urlParts['path'],
147
+			$payload_accessToken,
148
+			$timestamp,
149
+			$url2,
150
+			$this->payLoad];
151
+		$reqString = implode("%", $req);
152
+		$secret = self::SECRET;
153
+		$signature = hash_hmac('sha1', $reqString, $secret);
154
+		$signature = strtoupper($signature);
155
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
156
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
157
+		$headers['X-Timestamp'] = $timestamp;
158
+		$headers['X-Api-Version'] = '0.2';
159
+		return $headers;
160
+	}
161
+	private function getFullUrl()
162
+	{
163
+		return self::APIURL . $this->getApiEndPoint();
164
+	}
165
+	abstract function getApiEndPoint();
166
+	abstract function getMethod();
167
+	/**
168
+	 * @return string
169
+	 */
170
+	private function getAccessToken()
171
+	{
172
+		return $this->accessToken;
173
+	}
174
+	/**
175
+	 * @param string $accessToken
176
+	 */
177
+	public function setAccessToken($accessToken)
178
+	{
179
+		$this->accessToken = $accessToken;
180
+	}
181 181
 }
Please login to merge, or discard this patch.
php/Requests/GetCaptcha.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.