Skip to content

Commit

Permalink
disable new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
5baddi committed Jun 14, 2022
1 parent f6c81c3 commit b66bbcf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
14 changes: 5 additions & 9 deletions app/Domains/TwitterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ public function fetchTweetsByHashtags(string $hashtag, ?string $startTime = null
}
}

public static function sendDirectMessage(string $recipientId, string $message, ?string $senderId = null): void
public function sendDirectMessage(string $recipientId, string $message, ?string $senderId = null): void
{
// FIXME:
return;
try{
$body = [
'event' => [
Expand Down Expand Up @@ -150,27 +152,21 @@ public static function sendDirectMessage(string $recipientId, string $message, ?
);
}

$response = (new Client([
'base_uri' => self::BASE_API_V1_URL,
'debug' => false,
'http_errors' => false,
]))
$response = $this->getClient(1)
->request(
'POST',
self::DIRECT_MESSAGE_ENDPOINT,
[
'headers' => [
'Accept' => 'application/json',
'Authorization' => sprintf('Bearer %s', config('twitter.bearer_token'))
'Authorization' => sprintf('Bearer %s', config('twitter.bearer_token')) // FIXME: OAuth 2
],
'body' => json_encode($body)
]
);

$data = json_decode($response->getBody(), true);
dd($data);
} catch (Exception | ClientException | RequestException $e) {
dd($e);
AppLogger::error($e, 'twitter:send-direct-message');

throw new FetchByHashtagFailed();
Expand Down
3 changes: 2 additions & 1 deletion app/Jobs/Twitter/SendDirectMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function handle()
/** @var TwitterService $twitterService */
$twitterService = app(TwitterService::class);

$twitterService->sendDirectMessage($this->recipientId, $this->message, $this->senderId);
// FIXME:
// $twitterService->sendDirectMessage($this->recipientId, $this->message, $this->senderId);
} catch (Throwable $e) {
AppLogger::error($e, 'twitter:send-direct-message-job', get_object_vars($this));
}
Expand Down

0 comments on commit b66bbcf

Please sign in to comment.