-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathTwitterClient.php
More file actions
37 lines (30 loc) · 993 Bytes
/
TwitterClient.php
File metadata and controls
37 lines (30 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace CodelyTv\Mooc\Videos\Infrastructure\Share\Twitter;
use Abraham\TwitterOAuth\TwitterOAuth;
use CodelyTv\Mooc\Videos\Domain\VideoShare;
class TwitterClient implements VideoShare
{
private TwitterOAuth $connection;
public function __construct()
{
$twitter_consumer_key = $_SERVER['TWITTER_CONSUMER_KEY'];
$twitter_consumer_secret = $_SERVER['TWITTER_CONSUMER_SECRET'];
$twitter_access_token = $_SERVER['TWITTER_ACCESS_TOKEN'];
$twitter_access_token_secret = $_SERVER['TWITTER_ACCESS_TOKEN_SECRET'];
$this->connection = new TwitterOAuth (
$twitter_consumer_key,
$twitter_consumer_secret,
$twitter_access_token,
$twitter_access_token_secret
);
}
/**
* @param string $status
*
* @return array|object
*/
public function post(string $status)
{
return $this->connection->post("statuses/update", ["status" => $status]);
}
}