@@ -32,6 +32,10 @@ |
||
| 32 | 32 | { |
| 33 | 33 | return $this->random_str(64, 'abcdef0123456789'); |
| 34 | 34 | } |
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @param integer $length |
|
| 38 | + */ |
|
| 35 | 39 | function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
| 36 | 40 | { |
| 37 | 41 | $str = ''; |
@@ -1,66 +1,66 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class CreateUser extends AbstractRequest { |
| 4 | - /** |
|
| 5 | - * @var Location |
|
| 6 | - */ |
|
| 7 | - public $location; |
|
| 8 | - public $deviceUid; |
|
| 9 | - /** |
|
| 10 | - * @return Location |
|
| 11 | - */ |
|
| 12 | - public function getLocation(): Location |
|
| 13 | - { |
|
| 14 | - return $this->location; |
|
| 15 | - } |
|
| 16 | - /** |
|
| 17 | - * @param Location $location |
|
| 18 | - */ |
|
| 19 | - public function setLocation(Location $location) |
|
| 20 | - { |
|
| 21 | - $this->location = $location; |
|
| 22 | - } |
|
| 23 | - public function getDeviceUid() |
|
| 24 | - { |
|
| 4 | + /** |
|
| 5 | + * @var Location |
|
| 6 | + */ |
|
| 7 | + public $location; |
|
| 8 | + public $deviceUid; |
|
| 9 | + /** |
|
| 10 | + * @return Location |
|
| 11 | + */ |
|
| 12 | + public function getLocation(): Location |
|
| 13 | + { |
|
| 14 | + return $this->location; |
|
| 15 | + } |
|
| 16 | + /** |
|
| 17 | + * @param Location $location |
|
| 18 | + */ |
|
| 19 | + public function setLocation(Location $location) |
|
| 20 | + { |
|
| 21 | + $this->location = $location; |
|
| 22 | + } |
|
| 23 | + public function getDeviceUid() |
|
| 24 | + { |
|
| 25 | 25 | return $this->deviceUid; |
| 26 | 26 | } |
| 27 | 27 | public function setDeviceUid($deviceUid) |
| 28 | - { |
|
| 28 | + { |
|
| 29 | 29 | $this->deviceUid = $deviceUid; |
| 30 | 30 | } |
| 31 | - public function generateDeviceUid() |
|
| 32 | - { |
|
| 33 | - return $this->random_str(64, 'abcdef0123456789'); |
|
| 34 | - } |
|
| 35 | - function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
|
| 36 | - { |
|
| 37 | - $str = ''; |
|
| 38 | - $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 39 | - for ($i = 0; $i < $length; ++$i) { |
|
| 40 | - $str .= $keyspace[random_int(0, $max)]; |
|
| 41 | - } |
|
| 42 | - return $str; |
|
| 43 | - } |
|
| 44 | - function getApiEndPoint() |
|
| 45 | - { |
|
| 46 | - return '/v2/users'; |
|
| 47 | - } |
|
| 48 | - function getPayload() |
|
| 49 | - { |
|
| 31 | + public function generateDeviceUid() |
|
| 32 | + { |
|
| 33 | + return $this->random_str(64, 'abcdef0123456789'); |
|
| 34 | + } |
|
| 35 | + function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
|
| 36 | + { |
|
| 37 | + $str = ''; |
|
| 38 | + $max = mb_strlen($keyspace, '8bit') - 1; |
|
| 39 | + for ($i = 0; $i < $length; ++$i) { |
|
| 40 | + $str .= $keyspace[random_int(0, $max)]; |
|
| 41 | + } |
|
| 42 | + return $str; |
|
| 43 | + } |
|
| 44 | + function getApiEndPoint() |
|
| 45 | + { |
|
| 46 | + return '/v2/users'; |
|
| 47 | + } |
|
| 48 | + function getPayload() |
|
| 49 | + { |
|
| 50 | 50 | if(!isset($this->deviceUid)) |
| 51 | 51 | { |
| 52 | 52 | $this->setDeviceUid($this->generateDeviceUid()); |
| 53 | 53 | } |
| 54 | 54 | echo $this->getDeviceUid(); |
| 55 | - echo "<br>"; |
|
| 55 | + echo "<br>"; |
|
| 56 | 56 | return array( |
| 57 | 57 | "location" => $this->getLocation()->toArray(), |
| 58 | 58 | "client_id" => self::CLIENTID, |
| 59 | 59 | "device_uid" => $this->getDeviceUid(), |
| 60 | 60 | ); |
| 61 | - } |
|
| 62 | - function getMethod() |
|
| 63 | - { |
|
| 64 | - return 'POST'; |
|
| 65 | - } |
|
| 61 | + } |
|
| 62 | + function getMethod() |
|
| 63 | + { |
|
| 64 | + return 'POST'; |
|
| 65 | + } |
|
| 66 | 66 | } |
@@ -226,6 +226,7 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | /** |
| 228 | 228 | * Send a GET request |
| 229 | + * @param string $url |
|
| 229 | 230 | */ |
| 230 | 231 | public static function get($url, $headers = array(), $options = array()) { |
| 231 | 232 | return self::request($url, $headers, null, self::GET, $options); |
@@ -263,12 +264,14 @@ discard block |
||
| 263 | 264 | */ |
| 264 | 265 | /** |
| 265 | 266 | * Send a POST request |
| 267 | + * @param string $url |
|
| 266 | 268 | */ |
| 267 | 269 | public static function post($url, $headers = array(), $data = array(), $options = array()) { |
| 268 | 270 | return self::request($url, $headers, $data, self::POST, $options); |
| 269 | 271 | } |
| 270 | 272 | /** |
| 271 | 273 | * Send a PUT request |
| 274 | + * @param string $url |
|
| 272 | 275 | */ |
| 273 | 276 | public static function put($url, $headers = array(), $data = array(), $options = array()) { |
| 274 | 277 | return self::request($url, $headers, $data, self::PUT, $options); |
@@ -357,7 +357,7 @@ |
||
| 357 | 357 | * @param int $delta |
| 358 | 358 | * @param int $numpoints |
| 359 | 359 | * @param bool $firsttime |
| 360 | - * @return int New bias |
|
| 360 | + * @return double New bias |
|
| 361 | 361 | */ |
| 362 | 362 | protected static function adapt($delta, $numpoints, $firsttime) { |
| 363 | 363 | # function adapt(delta,numpoints,firsttime): |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * Returns false if $base is not absolute, otherwise an IRI. |
| 251 | 251 | * |
| 252 | - * @param IRI|string $base (Absolute) Base IRI |
|
| 252 | + * @param string $base (Absolute) Base IRI |
|
| 253 | 253 | * @param IRI|string $relative Relative IRI |
| 254 | 254 | * @return IRI|false |
| 255 | 255 | */ |
@@ -984,6 +984,7 @@ discard block |
||
| 984 | 984 | * Convert an IRI to a URI (or parts thereof) |
| 985 | 985 | * |
| 986 | 986 | * @param string|bool IRI to convert (or false from {@see get_iri}) |
| 987 | + * @param false|string $string |
|
| 987 | 988 | * @return string|false URI if IRI is valid, false otherwise. |
| 988 | 989 | */ |
| 989 | 990 | protected function to_uri($string) { |
@@ -232,7 +232,7 @@ |
||
| 232 | 232 | * |
| 233 | 233 | * @param array $request Request data (same form as {@see request_multiple}) |
| 234 | 234 | * @param boolean $merge_options Should we merge options as well? |
| 235 | - * @return array Request data |
|
| 235 | + * @return string Request data |
|
| 236 | 236 | */ |
| 237 | 237 | protected function merge_request($request, $merge_options = true) { |
| 238 | 238 | if ($this->url !== null) { |
@@ -29,7 +29,6 @@ |
||
| 29 | 29 | return $this->ancestor; |
| 30 | 30 | } |
| 31 | 31 | /** |
| 32 | - * @param Location $location |
|
| 33 | 32 | */ |
| 34 | 33 | public function setAncestor($ancestor) |
| 35 | 34 | { |
@@ -1,59 +1,59 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class SendJodel extends AbstractRequest { |
| 4 | - /** |
|
| 5 | - * @var Location |
|
| 6 | - */ |
|
| 7 | - public $location; |
|
| 8 | - /** |
|
| 9 | - * @return Location |
|
| 10 | - */ |
|
| 11 | - public function getLocation(): Location |
|
| 12 | - { |
|
| 13 | - return $this->location; |
|
| 14 | - } |
|
| 15 | - /** |
|
| 16 | - * @param Location $location |
|
| 17 | - */ |
|
| 18 | - public function setLocation(Location $location) |
|
| 19 | - { |
|
| 20 | - $this->location = $location; |
|
| 21 | - } |
|
| 4 | + /** |
|
| 5 | + * @var Location |
|
| 6 | + */ |
|
| 7 | + public $location; |
|
| 8 | + /** |
|
| 9 | + * @return Location |
|
| 10 | + */ |
|
| 11 | + public function getLocation(): Location |
|
| 12 | + { |
|
| 13 | + return $this->location; |
|
| 14 | + } |
|
| 15 | + /** |
|
| 16 | + * @param Location $location |
|
| 17 | + */ |
|
| 18 | + public function setLocation(Location $location) |
|
| 19 | + { |
|
| 20 | + $this->location = $location; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public $ancestor; |
|
| 24 | - /** |
|
| 25 | - * @return Location |
|
| 26 | - */ |
|
| 27 | - public function getAncestor() |
|
| 28 | - { |
|
| 29 | - return $this->ancestor; |
|
| 30 | - } |
|
| 31 | - /** |
|
| 32 | - * @param Location $location |
|
| 33 | - */ |
|
| 34 | - public function setAncestor($ancestor) |
|
| 35 | - { |
|
| 36 | - if(isset($ancestor) && $ancestor != "") |
|
| 37 | - { |
|
| 23 | + public $ancestor; |
|
| 24 | + /** |
|
| 25 | + * @return Location |
|
| 26 | + */ |
|
| 27 | + public function getAncestor() |
|
| 28 | + { |
|
| 29 | + return $this->ancestor; |
|
| 30 | + } |
|
| 31 | + /** |
|
| 32 | + * @param Location $location |
|
| 33 | + */ |
|
| 34 | + public function setAncestor($ancestor) |
|
| 35 | + { |
|
| 36 | + if(isset($ancestor) && $ancestor != "") |
|
| 37 | + { |
|
| 38 | 38 | $this->ancestor = $ancestor; |
| 39 | 39 | } |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - function getApiEndPoint() |
|
| 43 | - { |
|
| 44 | - return '/v3/posts/'; |
|
| 45 | - } |
|
| 46 | - function getPayload() |
|
| 47 | - { |
|
| 48 | - return array( |
|
| 42 | + function getApiEndPoint() |
|
| 43 | + { |
|
| 44 | + return '/v3/posts/'; |
|
| 45 | + } |
|
| 46 | + function getPayload() |
|
| 47 | + { |
|
| 48 | + return array( |
|
| 49 | 49 | "ancestor" => $this->getAncestor(), |
| 50 | 50 | "color" => "9EC41C", |
| 51 | - "location" => $this->getLocation()->toArray(), |
|
| 52 | - "message" => $_POST['message'], |
|
| 53 | - ); |
|
| 54 | - } |
|
| 55 | - function getMethod() |
|
| 56 | - { |
|
| 57 | - return 'POST'; |
|
| 58 | - } |
|
| 51 | + "location" => $this->getLocation()->toArray(), |
|
| 52 | + "message" => $_POST['message'], |
|
| 53 | + ); |
|
| 54 | + } |
|
| 55 | + function getMethod() |
|
| 56 | + { |
|
| 57 | + return 'POST'; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -40,6 +40,6 @@ |
||
| 40 | 40 | ) DEFAULT CHARSET=utf8"; |
| 41 | 41 | if(!$db->query($query)) |
| 42 | 42 | { |
| 43 | - throw new Exception($db->error($mysqli)); |
|
| 43 | + throw new Exception($db->error($mysqli)); |
|
| 44 | 44 | } |
| 45 | 45 | |
@@ -2,94 +2,94 @@ |
||
| 2 | 2 | |
| 3 | 3 | class AccountData |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * @var string |
|
| 7 | - */ |
|
| 8 | - public $accessToken; |
|
| 9 | - /** |
|
| 10 | - * @var string |
|
| 11 | - */ |
|
| 12 | - public $expirationDate; |
|
| 13 | - /** |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - public $refreshToken; |
|
| 17 | - /** |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - public $distinctId; |
|
| 21 | - /** |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - public $deviceUid; |
|
| 25 | - /** |
|
| 26 | - * @return string |
|
| 27 | - */ |
|
| 28 | - public function getAccessToken(): string |
|
| 29 | - { |
|
| 30 | - return $this->accessToken; |
|
| 31 | - } |
|
| 32 | - /** |
|
| 33 | - * @param string $accessToken |
|
| 34 | - */ |
|
| 35 | - public function setAccessToken(string $accessToken) |
|
| 36 | - { |
|
| 37 | - $this->accessToken = $accessToken; |
|
| 38 | - } |
|
| 39 | - /** |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getExpirationDate(): string |
|
| 43 | - { |
|
| 44 | - return $this->expirationDate; |
|
| 45 | - } |
|
| 46 | - /** |
|
| 47 | - * @param string $expirationDate |
|
| 48 | - */ |
|
| 49 | - public function setExpirationDate(string $expirationDate) |
|
| 50 | - { |
|
| 51 | - $this->expirationDate = $expirationDate; |
|
| 52 | - } |
|
| 53 | - /** |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public function getRefreshToken(): string |
|
| 57 | - { |
|
| 58 | - return $this->refreshToken; |
|
| 59 | - } |
|
| 60 | - /** |
|
| 61 | - * @param string $refreshToken |
|
| 62 | - */ |
|
| 63 | - public function setRefreshToken(string $refreshToken) |
|
| 64 | - { |
|
| 65 | - $this->refreshToken = $refreshToken; |
|
| 66 | - } |
|
| 67 | - /** |
|
| 68 | - * @return string |
|
| 69 | - */ |
|
| 70 | - public function getDistinctId(): string |
|
| 71 | - { |
|
| 72 | - return $this->distinctId; |
|
| 73 | - } |
|
| 74 | - /** |
|
| 75 | - * @param string $distinctId |
|
| 76 | - */ |
|
| 77 | - public function setDistinctId(string $distinctId) |
|
| 78 | - { |
|
| 79 | - $this->distinctId = $distinctId; |
|
| 80 | - } |
|
| 81 | - /** |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function getDeviceUid(): string |
|
| 85 | - { |
|
| 86 | - return $this->deviceUid; |
|
| 87 | - } |
|
| 88 | - /** |
|
| 89 | - * @param string $deviceUid |
|
| 90 | - */ |
|
| 91 | - public function setDeviceUid(string $deviceUid) |
|
| 92 | - { |
|
| 93 | - $this->deviceUid = $deviceUid; |
|
| 94 | - } |
|
| 5 | + /** |
|
| 6 | + * @var string |
|
| 7 | + */ |
|
| 8 | + public $accessToken; |
|
| 9 | + /** |
|
| 10 | + * @var string |
|
| 11 | + */ |
|
| 12 | + public $expirationDate; |
|
| 13 | + /** |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + public $refreshToken; |
|
| 17 | + /** |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + public $distinctId; |
|
| 21 | + /** |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + public $deviceUid; |
|
| 25 | + /** |
|
| 26 | + * @return string |
|
| 27 | + */ |
|
| 28 | + public function getAccessToken(): string |
|
| 29 | + { |
|
| 30 | + return $this->accessToken; |
|
| 31 | + } |
|
| 32 | + /** |
|
| 33 | + * @param string $accessToken |
|
| 34 | + */ |
|
| 35 | + public function setAccessToken(string $accessToken) |
|
| 36 | + { |
|
| 37 | + $this->accessToken = $accessToken; |
|
| 38 | + } |
|
| 39 | + /** |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getExpirationDate(): string |
|
| 43 | + { |
|
| 44 | + return $this->expirationDate; |
|
| 45 | + } |
|
| 46 | + /** |
|
| 47 | + * @param string $expirationDate |
|
| 48 | + */ |
|
| 49 | + public function setExpirationDate(string $expirationDate) |
|
| 50 | + { |
|
| 51 | + $this->expirationDate = $expirationDate; |
|
| 52 | + } |
|
| 53 | + /** |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public function getRefreshToken(): string |
|
| 57 | + { |
|
| 58 | + return $this->refreshToken; |
|
| 59 | + } |
|
| 60 | + /** |
|
| 61 | + * @param string $refreshToken |
|
| 62 | + */ |
|
| 63 | + public function setRefreshToken(string $refreshToken) |
|
| 64 | + { |
|
| 65 | + $this->refreshToken = $refreshToken; |
|
| 66 | + } |
|
| 67 | + /** |
|
| 68 | + * @return string |
|
| 69 | + */ |
|
| 70 | + public function getDistinctId(): string |
|
| 71 | + { |
|
| 72 | + return $this->distinctId; |
|
| 73 | + } |
|
| 74 | + /** |
|
| 75 | + * @param string $distinctId |
|
| 76 | + */ |
|
| 77 | + public function setDistinctId(string $distinctId) |
|
| 78 | + { |
|
| 79 | + $this->distinctId = $distinctId; |
|
| 80 | + } |
|
| 81 | + /** |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function getDeviceUid(): string |
|
| 85 | + { |
|
| 86 | + return $this->deviceUid; |
|
| 87 | + } |
|
| 88 | + /** |
|
| 89 | + * @param string $deviceUid |
|
| 90 | + */ |
|
| 91 | + public function setDeviceUid(string $deviceUid) |
|
| 92 | + { |
|
| 93 | + $this->deviceUid = $deviceUid; |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -3,18 +3,18 @@ |
||
| 3 | 3 | |
| 4 | 4 | class GetKarma extends AbstractRequest { |
| 5 | 5 | |
| 6 | - function getApiEndPoint() |
|
| 7 | - { |
|
| 8 | - return '/v2/users/karma'; |
|
| 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/users/karma'; |
|
| 9 | + } |
|
| 10 | + function getPayload() |
|
| 11 | + { |
|
| 12 | + return array( |
|
| 13 | + ); |
|
| 14 | + } |
|
| 15 | + function getMethod() |
|
| 16 | + { |
|
| 17 | + return 'GET'; |
|
| 18 | + } |
|
| 19 | 19 | } |
| 20 | 20 | |