diff --git a/composer.json b/composer.json index 3861443..6d66737 100755 --- a/composer.json +++ b/composer.json @@ -19,10 +19,10 @@ } ], "require": { - "php": "^7.2", + "php": "^8.1", "ext-curl": "*", "ext-json": "*", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0" + "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", diff --git a/src/RedditAPI.php b/src/RedditAPI.php index 8dd41a0..d558dbf 100644 --- a/src/RedditAPI.php +++ b/src/RedditAPI.php @@ -2851,12 +2851,12 @@ public function searchSubredditsByTopic($query): array public function subscribe($subreddit) { $subreddit_info = $this->aboutSubreddit($subreddit); - if (!isset($subreddit_info->data->name)) { + if (!isset($subreddit_info["data"]["name"])) { return null; } $params = [ 'action' => 'sub', - 'sr' => $subreddit_info->data->name, + 'sr' => $subreddit_info["data"]["name"], ]; return $this->apiCall('/api/subscribe', 'POST', $params); @@ -2872,12 +2872,12 @@ public function subscribe($subreddit) public function unsubscribe($subreddit) { $subreddit_info = $this->aboutSubreddit($subreddit); - if (!isset($subreddit_info->data->name)) { + if (!isset($subreddit_info["data"]["name"])) { return null; } $params = [ 'action' => 'unsub', - 'sr' => $subreddit_info->data->name, + 'sr' => $subreddit_info["data"]["name"], ]; return $this->apiCall('/api/subscribe', 'POST', $params); diff --git a/src/RedditRateLimiter.php b/src/RedditRateLimiter.php index e23337c..0f5d2a5 100644 --- a/src/RedditRateLimiter.php +++ b/src/RedditRateLimiter.php @@ -52,7 +52,7 @@ public function wait(): void $now = microtime(true) * 10000; $wait_until = $this->last_request + ($this->interval * 10000); if ($this->enabled && $now < $wait_until) { - usleep(($wait_until - $now) * 100); + usleep(round(($wait_until - $now) * 100)); } $this->last_request = microtime(true) * 10000; }