-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathTweets.php
More file actions
146 lines (129 loc) · 3.3 KB
/
Copy pathTweets.php
File metadata and controls
146 lines (129 loc) · 3.3 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
namespace Coderjerk\BirdElephant;
use Coderjerk\BirdElephant\Tweets\TweetLookup;
use Coderjerk\BirdElephant\Tweets\TweetCounts;
use Coderjerk\BirdElephant\Tweets\Search;
use Coderjerk\BirdElephant\Tweets\Reply;
use Coderjerk\BirdElephant\Tweets\Likes;
use Coderjerk\BirdElephant\Tweets\Retweets;
use Coderjerk\BirdElephant\Tweets\ManageTweets;
use GuzzleHttp\Exception\GuzzleException;
class Tweets
{
protected array $credentials;
public TweetLookup $lookup;
public Likes $likes;
public Retweets $retweets;
public ManageTweets $manageTweets;
public function __construct(array $credentials)
{
$this->credentials = $credentials;
$this->lookup = new TweetLookup($this->credentials);
$this->likes = new Likes($this->credentials);
$this->retweets = new Retweets($this->credentials);
$this->manageTweets = new ManageTweets($this->credentials);
}
/**
* Get a single tweet
*
* @param string $id
* @param array $params
* @return object
* @throws GuzzleException
*/
public function get(string $id, array $params = []): object
{
return $this->lookup->getTweet($id, $params);
}
/**
* Get multiple Tweets
*
* @param array $ids
* @param array $params
* @return object
* @throws GuzzleException
*/
public function lookup(array $ids, array $params = []): object
{
return $this->lookup->getTweets($ids, $params);
}
/**
* Get tweet counts
*
* @return TweetCounts
*/
public function count(): TweetCounts
{
return new TweetCounts($this->credentials);
}
/**
* Search tweets
*
* @return Search
*/
public function search(): Search
{
return new Search($this->credentials);
}
/**
* Hide or unhide a reply belonging to a conversation
* initiated by the authenticating user.
*
* @return Reply
*/
public function reply(): Reply
{
return new Reply($this->credentials);
}
/**
* Get users who've liked a given tweet
*
* @param string $id - tweet id
* @param array $params
* @return object
* @throws GuzzleException
*/
public function likers(string $id, array $params = []): object
{
return $this->likes->likingUsers($id, $params);
}
/**
* Get users who've retweeted a given tweet
*
* @param string $id - tweet id
* @return object
* @throws GuzzleException
*/
public function retweeters(string $id, array $params = []): object
{
return $this->retweets->retweetedBy($id, $params);
}
/**
* Send a tweet
*
* @param object $tweet
* @return object
*/
public function tweet(object $tweet): object
{
return $this->manageTweets->send($tweet);
}
/**
* @param string $tweet_id
* @return object
* @throws GuzzleException
*/
public function delete(string $tweet_id): object
{
return $this->manageTweets->unsend($tweet_id);
}
/**
* @param $file
* @return object
* @throws GuzzleException
*/
public function upload($file, ?string $mimeType = null): object
{
return $this->manageTweets->mediaUpload($file, $mimeType);
}
}