Completed
Push — master ( 8c6b3e...6fce2f )
by mains
02:42
created
php/Requests/Downvote.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@
 block discarded – undo
1 1
 <?php
2 2
 class Downvote extends AbstractRequest
3 3
 {
4
-    public $postId;
4
+	public $postId;
5 5
 		
6
-    function getApiEndPoint()
7
-    {
8
-        return '/v2/posts/' . $this->postId . '/downvote';
9
-    }
10
-    function getPayload()
11
-    {
12
-        return array(
13
-        );
14
-    }
15
-    function getMethod()
16
-    {
17
-        return 'PUT';
18
-    }
6
+	function getApiEndPoint()
7
+	{
8
+		return '/v2/posts/' . $this->postId . '/downvote';
9
+	}
10
+	function getPayload()
11
+	{
12
+		return array(
13
+		);
14
+	}
15
+	function getMethod()
16
+	{
17
+		return 'PUT';
18
+	}
19 19
 }
20 20
 
Please login to merge, or discard this patch.
php/Requests/Upvote.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 class Upvote extends AbstractRequest {
3 3
 		
4
-    public $postId;
4
+	public $postId;
5 5
 
6
-    function getApiEndPoint()
7
-    {
8
-        return '/v2/posts/' . $this->postId . '/upvote';
9
-    }
10
-    function getPayload()
11
-    {
12
-        return array(
6
+	function getApiEndPoint()
7
+	{
8
+		return '/v2/posts/' . $this->postId . '/upvote';
9
+	}
10
+	function getPayload()
11
+	{
12
+		return array(
13 13
 					"reason_code" => -1,
14
-        );
15
-    }
16
-    function getMethod()
17
-    {
18
-        return 'PUT';
19
-    }
14
+		);
15
+	}
16
+	function getMethod()
17
+	{
18
+		return 'PUT';
19
+	}
20 20
 }
21 21
 
Please login to merge, or discard this patch.
php/Requests/AbstractRequest.php 1 patch
Indentation   +116 added lines, -116 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 = 'plerFToqEdWlzShdZlTywaCHRuzlKIMsNmOJVDGE';
8
-    const USERAGENT = 'Jodel/4.31.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
-    const CLIENT_TYPE = 'android_4.31.1';
5
+	const CLIENTID = '81e8a76e-1e02-4d17-9ba0-8a7020261b26';
6
+	const APIURL = 'https://api.go-tellm.com/api';
7
+	const SECRET = 'plerFToqEdWlzShdZlTywaCHRuzlKIMsNmOJVDGE';
8
+	const USERAGENT = 'Jodel/4.31.1 Dalvik/2.1.0 (Linux; U; Android 5.1.1; )';
9
+	const CLIENT_TYPE = 'android_4.31.1';
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,79 +24,79 @@  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
         var_dump($url);
38 38
         var_dump($header);
39 39
         var_dump($this->payLoad);
40 40
         */
41 41
         
42 42
 
43
-        switch ($this->getMethod()) {
44
-            case 'POST':
45
-                $result = Requests::post($url, $header, $this->payLoad);
46
-                break;
47
-            case 'GET':
48
-                if($this->version == 'v3')
49
-                {
50
-                    $result = Requests::get($url, $header);
51
-                }
52
-                else
53
-                {
54
-                    $result = Requests::get($url, $header);
55
-                }
56
-                break;
57
-            case 'PUT':
58
-                $result = Requests::put($url, $header, $this->payLoad);
59
-                break;
60
-        }
61
-        switch ($result->status_code) {
62
-            case 200:
63
-                $result = json_decode($result->body, true);
64
-                break;
65
-            case 204:
66
-                $result = "Success";
67
-                break;
68
-            case 401:
43
+		switch ($this->getMethod()) {
44
+			case 'POST':
45
+				$result = Requests::post($url, $header, $this->payLoad);
46
+				break;
47
+			case 'GET':
48
+				if($this->version == 'v3')
49
+				{
50
+					$result = Requests::get($url, $header);
51
+				}
52
+				else
53
+				{
54
+					$result = Requests::get($url, $header);
55
+				}
56
+				break;
57
+			case 'PUT':
58
+				$result = Requests::put($url, $header, $this->payLoad);
59
+				break;
60
+		}
61
+		switch ($result->status_code) {
62
+			case 200:
63
+				$result = json_decode($result->body, true);
64
+				break;
65
+			case 204:
66
+				$result = "Success";
67
+				break;
68
+			case 401:
69 69
 				//throw new \Exception('Unauthorized');
70
-                break;
71
-            case 404:
72
-                //echo "Es wurde bereits gevoted";
70
+				break;
71
+			case 404:
72
+				//echo "Es wurde bereits gevoted";
73 73
 			case 477:
74
-                //echo "Es wurde bereits gevoted";
75
-                //throw  new \Exception('Signing failed!');
76
-                break;
77
-            default:
78
-                throw  new \Exception('Unknown Error: '.$result->status_code);
79
-        }
74
+				//echo "Es wurde bereits gevoted";
75
+				//throw  new \Exception('Signing failed!');
76
+				break;
77
+			default:
78
+				throw  new \Exception('Unknown Error: '.$result->status_code);
79
+		}
80 80
 
81
-        if($device_uid != "")
82
-        {
81
+		if($device_uid != "")
82
+		{
83 83
 			$result[0] = $result;
84 84
 			$result[1] = $device_uid;
85 85
 		}
86 86
 
87 87
         
88
-        /*var_dump($result);*/
88
+		/*var_dump($result);*/
89 89
         
90 90
 
91
-        return $result;
92
-    }
93
-    abstract function getPayload();
94
-    /**
95
-     * Gets Sign headers
96
-     * @return array headers
97
-     */
98
-    private function getSignHeaders()
99
-    {
91
+		return $result;
92
+	}
93
+	abstract function getPayload();
94
+	/**
95
+	 * Gets Sign headers
96
+	 * @return array headers
97
+	 */
98
+	private function getSignHeaders()
99
+	{
100 100
 			if($this->getAccessToken() == null) {
101 101
 				$payload_accessToken = "";
102 102
 			}
@@ -105,54 +105,54 @@  discard block
 block discarded – undo
105 105
 			}
106 106
 			
107 107
 			
108
-        $headers = array(
109
-            "Connection" => "keep-alive",
110
-            "Accept-Encoding" => "gzip",
111
-            "Content-Type" => "application/json; charset=UTF-8",
112
-            "User-Agent" => self::USERAGENT
113
-        );
114
-        $timestamp = new DateTime();
115
-        $timestamp = $timestamp->format(DateTime::ATOM);
116
-        $timestamp = substr($timestamp, 0, -6);
117
-        $timestamp .= "Z";
118
-        $urlParts = parse_url($this->getFullUrl());
119
-        $url2 = "";
120
-        $req = [$this->getMethod(),
121
-            $urlParts['host'],
122
-            "443",
123
-            $urlParts['path'],
124
-            $payload_accessToken,
125
-            $timestamp,
126
-            $url2,
127
-            $this->payLoad];
128
-        $reqString = implode("%", $req);
129
-        $secret = self::SECRET;
130
-        $signature = hash_hmac('sha1', $reqString, $secret);
131
-        $signature = strtoupper($signature);
132
-        $headers['X-Authorization'] = 'HMAC ' . $signature;
133
-        $headers['X-Client-Type'] = self::CLIENT_TYPE;
134
-        $headers['X-Timestamp'] = $timestamp;
135
-        $headers['X-Api-Version'] = '0.2';
136
-        return $headers;
137
-    }
138
-    private function getFullUrl()
139
-    {
140
-        return self::APIURL . $this->getApiEndPoint();
141
-    }
142
-    abstract function getApiEndPoint();
143
-    abstract function getMethod();
144
-    /**
145
-     * @return string
146
-     */
147
-    private function getAccessToken()
148
-    {
149
-        return $this->accessToken;
150
-    }
151
-    /**
152
-     * @param string $accessToken
153
-     */
154
-    public function setAccessToken($accessToken)
155
-    {
156
-        $this->accessToken = $accessToken;
157
-    }
108
+		$headers = array(
109
+			"Connection" => "keep-alive",
110
+			"Accept-Encoding" => "gzip",
111
+			"Content-Type" => "application/json; charset=UTF-8",
112
+			"User-Agent" => self::USERAGENT
113
+		);
114
+		$timestamp = new DateTime();
115
+		$timestamp = $timestamp->format(DateTime::ATOM);
116
+		$timestamp = substr($timestamp, 0, -6);
117
+		$timestamp .= "Z";
118
+		$urlParts = parse_url($this->getFullUrl());
119
+		$url2 = "";
120
+		$req = [$this->getMethod(),
121
+			$urlParts['host'],
122
+			"443",
123
+			$urlParts['path'],
124
+			$payload_accessToken,
125
+			$timestamp,
126
+			$url2,
127
+			$this->payLoad];
128
+		$reqString = implode("%", $req);
129
+		$secret = self::SECRET;
130
+		$signature = hash_hmac('sha1', $reqString, $secret);
131
+		$signature = strtoupper($signature);
132
+		$headers['X-Authorization'] = 'HMAC ' . $signature;
133
+		$headers['X-Client-Type'] = self::CLIENT_TYPE;
134
+		$headers['X-Timestamp'] = $timestamp;
135
+		$headers['X-Api-Version'] = '0.2';
136
+		return $headers;
137
+	}
138
+	private function getFullUrl()
139
+	{
140
+		return self::APIURL . $this->getApiEndPoint();
141
+	}
142
+	abstract function getApiEndPoint();
143
+	abstract function getMethod();
144
+	/**
145
+	 * @return string
146
+	 */
147
+	private function getAccessToken()
148
+	{
149
+		return $this->accessToken;
150
+	}
151
+	/**
152
+	 * @param string $accessToken
153
+	 */
154
+	public function setAccessToken($accessToken)
155
+	{
156
+		$this->accessToken = $accessToken;
157
+	}
158 158
 }
Please login to merge, or discard this patch.