-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweet.php
executable file
·238 lines (176 loc) · 5.34 KB
/
tweet.php
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
/**/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$d = file_get_contents('data');
$d= json_decode($d);
$count=500;
$emojis=[😋,😀,❤️,💛,💚,💙,💜,😍,😊,☺️,😇,🆘,🚨];
$hashtags=[
'#Rescue',
'#adoptdontshop',
'#Foster',
'#PetRescue',
'#Adoption',
'#PetAdoption',
'#AnimalLove',
'#AdoptMe',
'#savealife',
'#adoptdontshop'
];
$hashtagtwo=[
'#spca',
'#NYC',
'#petlovers',
'#urgent'];
echo "boooom";
if (rand(0,10)>6){
$petemoji=[😺,😸,😹,😻,😽];
array_push($hashtagtwo,'#catsoftwitter,#catlovers','#catlover','#cats');
$response = file_get_contents("http://api.petfinder.com/pet.find?format=json&key=*/Your_API_Key*/&callback=?&count=".$count."&animal=cat&location=10001");
}else{
$petemoji=[🐕,🐾,🐶];
array_push($hashtagtwo,'#dogsoftwitter','#rescuedogs','#doglovers','#puppylove','#dogs');
$response = file_get_contents("http://api.petfinder.com/pet.find?format=json&key=*/Your_API_Key*/&callback=?&count=".$count."&animal=dog&location=10001");
}
$response=str_replace('$t','param',$response);
$response=substr($response, 2);
$response=substr($response, 0, -2);
$response=json_decode($response);
for ($i=0;$i<$count;$i++){
if (isset($response->petfinder->pets->pet[0]->media->photos->photo[2])){
if (!in_array((string)$response->petfinder->pets->pet[$i]->id->param,$d)){
if (isset($tempi)){
if (strtotime($response->petfinder->pets->pet[$i]->lastUpdate->param)<$lowestdate){
$tempi=$i;
$lowestdate=strtotime($response->petfinder->pets->pet[$i]->lastUpdate->param);
}
}else{
$tempi=$i;
$lowestdate=strtotime($response->petfinder->pets->pet[$i]->lastUpdate->param);
}
}
}
}
$picture=$response->petfinder->pets->pet[$tempi]->media->photos->photo[2]->param;
if (isset($response->petfinder->pets->pet[$tempi]->media->photos->photo[7])){
$picturetwo=$response->petfinder->pets->pet[$tempi]->media->photos->photo[7]->param;
}
//*******************************************************
//$response->petfinder->pets->pet[$i]->id->param
//$response->petfinder->pets->pet[$i]->name->param
$prefixtxt=[
"Come rescue",
"Come help",
"Come adopt",
"Come pick up",
"Come meet",
"Come snuggle",
"Come visit",
"Say hi to",
"Meet",
"Rescue",
"Help",
"Adopt",
"Pick up",
"Snuggle",
"Visit"
];
$suffixtxt=[
"now!",
"today!",
"ASAP!",
"pronto!",
"!",
"today!",
"before time runs out!",
"before it's too late!",
"today!",
"!",
"now!",
"soon!"
];
$explanatory=[
"'s such a cutie!",
"'s so sweet!",
" can be your best friend!",
" has so much love to give!",
"'s so affectionate!",
" wants to be your new buddy!",
"'s waiting for you!",
" wants to play!",
"'s ready for snuggles!",
" wants to meet you!",
" wants to love you!",
"'s the sweetest!",
"'s the cuddliest!",
" needs your help!",
" wants to come home with you!",
"'s your new best friend!",
" needs your love!",
" needs a friend!",
"'s the perfect companion!",
" needs your support!",
" needs your generosity!",
"'s the perfect friend!",
"'s the most wonderful pet!",
"'s the most adorable!",
"'s the loveliest!",
" needs a loving home!",
" needs your TLC!",
" wants to be part of your life!",
"'d love a RT!",
" needs as many RTs as possible!",
" needs this seen far and wide!",
" needs a furever home!",
" needs some RTs!",
" wants some hugs!",
" would love a RT or two!"
];
$hashnum=rand(0,count($hashtags)-1);
$explnum=rand(0,count($explanatory)-1);
$suffixnum=rand(0,count($suffixtxt)-1);
$prefixnum=rand(0,count($prefixtxt)-1);
//$hashtagtwo,$petemoji,$emojis
$petemojinum=rand(0,count($petemoji)-1);
$emojisnum=rand(0,count($emojis)-1);
$hashtagtwonum=rand(0,count($hashtagtwo)-1);
if ($response->petfinder->pets->pet[$tempi]->sex->param=="F"){
$gender="She";
}else{
$gender="He";
}
$url='https://www.petfinder.com/petdetail/'.$response->petfinder->pets->pet[$tempi]->id->param;
$name=$response->petfinder->pets->pet[$tempi]->name->param;
$name=strtoupper(preg_replace('/\W.+|\W+/i', '', $name));
// $name regex delete anything after space or punctuation
//$loc=$response->petfinder->pets->pet[$tempi]->contact->city->param;
//$hashtagtwo,$petemoji,$emojis
//$petemojinum,$emojisnum,$hashtagtwonum
$tweet=$petemoji[$petemojinum].' '.$prefixtxt[$prefixnum].' #'.$name.' '.$suffixtxt[$suffixnum].' '.$hashtagtwo[$hashtagtwonum].' '.$gender.$explanatory[$explnum].' '.$emojis[$emojisnum].' '.$hashtags[$hashnum].' '.$url;
//*******************************************************
require "inc/twitter_credentials.php";
require "vendor/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$media1 = $connection->upload('media/upload', ['media' => $picture]);
// && rand(0,10)>1
if (isset($picturetwo)){
$media2 = $connection->upload('media/upload', ['media' => $picturetwo]);
$parameters = [
'status' => $tweet,
'media_ids' => implode(',', [$media1->media_id_string, $media2->media_id_string])
//'media_ids' => implode(',', [$media1->media_id_string, $media2->media_id_string])
];
}else{
$parameters = [
'status' => $tweet,
'media_ids' => [$media1->media_id_string]
];
}
$result = $connection->post('statuses/update', $parameters);
array_push($d,$response->petfinder->pets->pet[$tempi]->id->param);
$d=json_encode($d);
file_put_contents('data', $d);
?>