-
Notifications
You must be signed in to change notification settings - Fork 798
/
Copy pathEndpoints.php
308 lines (253 loc) · 13 KB
/
Endpoints.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<?php
namespace InstagramScraper;
class Endpoints
{
const BASE_URL = 'https://www.instagram.com';
const LOGIN_URL = 'https://www.instagram.com/accounts/login/ajax/';
const ACCOUNT_PAGE = 'https://www.instagram.com/api/v1/users/web_profile_info/?username={username}';
const MEDIA_LINK = 'https://www.instagram.com/p/{code}';
const ACCOUNT_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=e769aa130647d2354c40ea6a439bfc08&variables={variables}';
const ACCOUNT_TAGGED_MEDIAS = 'https://www.instagram.com/graphql/query/?query_hash=be13233562af2d229b008d2976b998b5&variables={variables}';
const ACCOUNT_JSON_INFO = 'https://www.instagram.com/{username}/?__a=1&__d=dis';
const ACCOUNT_ACTIVITY = 'https://www.instagram.com/accounts/activity/?__a=1';
const MEDIA_JSON_INFO = 'https://www.instagram.com/p/{code}/?__a=1&__d=dis';
const MEDIA_JSON_BY_LOCATION_ID = 'https://www.instagram.com/explore/locations/{{facebookLocationId}}/?__a=1&max_id={{maxId}}';
const MEDIA_JSON_BY_TAG = 'https://www.instagram.com/explore/tags/{tag}/?__a=1&max_id={max_id}&__d=dis';
const GENERAL_SEARCH = 'https://www.instagram.com/web/search/topsearch/?query={query}&count={count}';
const ACCOUNT_JSON_INFO_BY_ID = 'ig_user({userId}){id,username,external_url,full_name,profile_pic_url,biography,followed_by{count},follows{count},media{count},is_private,is_verified}';
const COMMENTS_BEFORE_COMMENT_ID_BY_CODE = 'https://www.instagram.com/graphql/query/?query_hash=33ba35852cb50da46f5b5e889df7d159&variables={variables}';
const LAST_LIKES_BY_CODE = 'ig_shortcode({{code}}){likes{nodes{id,user{id,profile_pic_url,username,follows{count},followed_by{count},biography,full_name,media{count},is_private,external_url,is_verified}},page_info}}';
const LIKES_BY_SHORTCODE = 'https://www.instagram.com/graphql/query/?query_id=17864450716183058&variables={"shortcode":"{{shortcode}}","first":{{count}},"after":"{{likeId}}"}';
const FOLLOWING_URL = 'https://www.instagram.com/graphql/query/?query_id=17874545323001329&id={{accountId}}&first={{count}}&after={{after}}';
const FOLLOWERS_URL = 'https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={{accountId}}&first={{count}}&after={{after}}';
const FOLLOWING_URL_V1 = 'https://i.instagram.com/api/v1/friendships/{{accountId}}/following/';
const FOLLOWERS_URL_V1 = 'https://i.instagram.com/api/v1/friendships/{{accountId}}/followers/';
const FOLLOW_URL = 'https://www.instagram.com/web/friendships/{{accountId}}/follow/';
const UNFOLLOW_URL = 'https://www.instagram.com/web/friendships/{{accountId}}/unfollow/';
const REMOVE_FOLLOWER_URL = 'https://www.instagram.com/web/friendships/{{accountId}}/remove_follower/';
const PENDING_URL = 'https://i.instagram.com/api/v1/friendships/pending/';
const INBOX_NEWS_URL = 'https://i.instagram.com/api/v1/news/inbox/';
const INBOX_NEWS_SEEN_URL = 'https://i.instagram.com/api/v1/news/inbox_seen/';
const USER_TAGS = 'https://i.instagram.com/api/v1/usertags/{{accountId}}/feed/?count={{count}}';
const USER_FEED = 'https://www.instagram.com/graphql/query/?query_id=17861995474116400&fetch_media_item_count=12&fetch_media_item_cursor=&fetch_comment_count=4&fetch_like=10';
const USER_FEED2 = 'https://www.instagram.com/?__a=1';
const USER_FEED_hash = 'https://www.instagram.com/graphql/query/?query_hash=3f01472fb28fb8aca9ad9dbc9d4578ff';
const INSTAGRAM_QUERY_URL = 'https://www.instagram.com/query/';
const INSTAGRAM_CDN_URL = 'https://scontent.cdninstagram.com/';
const ACCOUNT_JSON_PRIVATE_INFO_BY_ID = 'https://i.instagram.com/api/v1/users/{userId}/info/';
const ACCOUNT_JSON_PRIVATE_INFO_BY_ID_2 = 'https://www.instagram.com/graphql/query/?query_hash=c9100bf9110dd6361671f113dd02e7d6&variables={"user_id":"{userId}","include_chaining":false,"include_reel":true,"include_suggested_users":false,"include_logged_out_extras":false,"include_highlight_reels":false,"include_related_profiles":false}';
const LIKE_URL = 'https://www.instagram.com/web/likes/{mediaId}/like/';
const UNLIKE_URL = 'https://www.instagram.com/web/likes/{mediaId}/unlike/';
const ADD_COMMENT_URL = 'https://www.instagram.com/web/comments/{mediaId}/add/';
const DELETE_COMMENT_URL = 'https://www.instagram.com/web/comments/{mediaId}/delete/{commentId}/';
const ACCOUNT_MEDIAS2 = 'https://www.instagram.com/graphql/query/?query_id=17880160963012870&id={{accountId}}&first=10&after=';
const HIGHLIGHT_URL = 'https://www.instagram.com/graphql/query/?query_hash=c9100bf9110dd6361671f113dd02e7d6&variables={"user_id":"{userId}","include_chaining":false,"include_reel":true,"include_suggested_users":false,"include_logged_out_extras":false,"include_highlight_reels":true,"include_live_status":false}';
const HIGHLIGHT_STORIES = 'https://www.instagram.com/graphql/query/?query_hash=45246d3fe16ccc6577e0bd297a5db1ab';
const THREADS_URL = 'https://i.instagram.com/api/v1/direct_v2/inbox/?persistentBadging=true&folder=&limit={limit}&thread_message_limit={messageLimit}&cursor={cursor}';
const THREADS_PENDING_REQUESTS_URL = 'https://i.instagram.com/api/v1/direct_v2/pending_inbox/?limit={limit}&cursor={cursor}';
const THREADS_APPROVE_MULTIPLE_URL = 'https://i.instagram.com/api/v1/direct_v2/threads/approve_multiple/';
// Look alike??
const URL_SIMILAR = 'https://www.instagram.com/graphql/query/?query_id=17845312237175864&id=4663052';
const GRAPH_QL_QUERY_URL = 'https://www.instagram.com/graphql/query/?query_id={{queryId}}';
private static $requestMediaCount = 30;
/**
* @param int $count
*/
public static function setAccountMediasRequestCount($count)
{
static::$requestMediaCount = $count;
}
public static function getAccountMediasRequestCount()
{
return static::$requestMediaCount;
}
public static function getAccountPageLink($username)
{
return str_replace('{username}', urlencode($username), static::ACCOUNT_PAGE);
}
public static function getAccountJsonLink($username)
{
return str_replace('{username}', urlencode($username), static::ACCOUNT_JSON_INFO);
}
public static function getAccountJsonInfoLinkByAccountId($id)
{
return str_replace('{userId}', urlencode($id), static::ACCOUNT_JSON_INFO_BY_ID);
}
public static function getAccountJsonPrivateInfoLinkByAccountId($id)
{
return str_replace('{userId}', urlencode($id), static::ACCOUNT_JSON_PRIVATE_INFO_BY_ID_2);
}
public static function getAccountMediasJsonLink($variables)
{
return str_replace('{variables}', urlencode($variables), static::ACCOUNT_MEDIAS);
}
public static function getAccountTaggedMediasJsonLink($variables)
{
return str_replace('{variables}', urlencode($variables), static::ACCOUNT_TAGGED_MEDIAS);
}
public static function getMediaPageLink($code)
{
return str_replace('{code}', urlencode($code), static::MEDIA_LINK);
}
public static function getMediaJsonLink($code)
{
return str_replace('{code}', urlencode($code), static::MEDIA_JSON_INFO);
}
public static function getMediasJsonByLocationIdLink($facebookLocationId, $maxId = '')
{
$url = str_replace('{{facebookLocationId}}', urlencode($facebookLocationId), static::MEDIA_JSON_BY_LOCATION_ID);
return str_replace('{{maxId}}', urlencode($maxId), $url);
}
public static function getMediasJsonByTagLink($tag, $maxId = '')
{
$url = str_replace('{tag}', urlencode($tag), static::MEDIA_JSON_BY_TAG);
return str_replace('{max_id}', urlencode($maxId), $url);
}
public static function getGeneralSearchJsonLink($query, $count = 10)
{
$url = str_replace('{query}', urlencode($query), static::GENERAL_SEARCH);
return str_replace('{count}', urlencode($count), $url);
}
public static function getCommentsBeforeCommentIdByCode($variables)
{
return str_replace('{variables}', urlencode($variables), static::COMMENTS_BEFORE_COMMENT_ID_BY_CODE);
}
public static function getLastLikesByCodeLink($code)
{
$url = str_replace('{{code}}', urlencode($code), static::LAST_LIKES_BY_CODE);
return $url;
}
public static function getLastLikesByCode($code, $count, $lastLikeID)
{
$url = str_replace('{{shortcode}}', urlencode($code), static::LIKES_BY_SHORTCODE);
$url = str_replace('{{count}}', urlencode($count), $url);
$url = str_replace('{{likeId}}', urlencode($lastLikeID), $url);
return $url;
}
public static function getActivityUrl()
{
return static::ACCOUNT_ACTIVITY;
}
public static function getFollowUrl($accountId)
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOW_URL);
return $url;
}
public static function getUnfollowUrl($accountId)
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::UNFOLLOW_URL);
return $url;
}
public static function getRemoveFollowerUrl($accountId)
{
return str_replace('{{accountId}}', urlencode($accountId), static::REMOVE_FOLLOWER_URL);
}
public static function getPendingUrl()
{
return static::PENDING_URL;
}
public static function getInboxNewsUrl()
{
return static::INBOX_NEWS_URL;
}
public static function getInboxNewsSeenUrl()
{
return static::INBOX_NEWS_SEEN_URL;
}
public static function getUserTagsUrl($accountId, $count = 12)
{
return str_replace(['{{accountId}}', '{{count}}'], [urlencode($accountId), urlencode($count)], static::USER_TAGS);
}
public static function getFollowersJsonLink($accountId, $count, $after = '')
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWERS_URL);
$url = str_replace('{{count}}', urlencode($count), $url);
if ($after === '') {
$url = str_replace('&after={{after}}', '', $url);
} else {
$url = str_replace('{{after}}', urlencode($after), $url);
}
return $url;
}
public static function getFollowingJsonLink($accountId, $count, $after = '')
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWING_URL);
$url = str_replace('{{count}}', urlencode($count), $url);
if ($after === '') {
$url = str_replace('&after={{after}}', '', $url);
} else {
$url = str_replace('{{after}}', urlencode($after), $url);
}
return $url;
}
public static function getFollowersUrl_v1($accountId)
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWERS_URL_V1);
return $url;
}
public static function getFollowingUrl_v1($accountId)
{
$url = str_replace('{{accountId}}', urlencode($accountId), static::FOLLOWING_URL_V1);
return $url;
}
public static function getUserStoriesLink($variables=[])
{
$url = self::getGraphQlUrl(InstagramQueryId::USER_STORIES, ['variables' => json_encode($variables)]);
return $url;
}
public static function getGraphQlUrl($queryId, $parameters)
{
$url = str_replace('{{queryId}}', urlencode($queryId), static::GRAPH_QL_QUERY_URL);
if (!empty($parameters)) {
$query_string = http_build_query($parameters);
$url .= '&' . $query_string;
}
return $url;
}
public static function getStoriesLink($variables)
{
$url = self::getGraphQlUrl(InstagramQueryId::STORIES, ['variables' => json_encode($variables)]);
return $url;
}
public static function getLikeUrl($mediaId)
{
return str_replace('{mediaId}', urlencode($mediaId), static::LIKE_URL);
}
public static function getUnlikeUrl($mediaId)
{
return str_replace('{mediaId}', urlencode($mediaId), static::UNLIKE_URL);
}
public static function getAddCommentUrl($mediaId)
{
return str_replace('{mediaId}', $mediaId, static::ADD_COMMENT_URL);
}
public static function getDeleteCommentUrl($mediaId, $commentId)
{
$url = str_replace('{mediaId}', $mediaId, static::DELETE_COMMENT_URL);
$url = str_replace('{commentId}', $commentId, $url);
return $url;
}
public static function getHighlightUrl($id)
{
return str_replace('{userId}', urlencode($id), static::HIGHLIGHT_URL);
}
public static function getThreadsUrl($limit, $messageLimit, $cursor)
{
$url = static::THREADS_URL;
$url = str_replace('{limit}', $limit, $url);
$url = str_replace('{messageLimit}', $messageLimit, $url);
$url = str_replace('{cursor}', $cursor, $url);
return $url;
}
public static function getThreadsPendingRequestsUrl($limit, $cursor = null)
{
$url = static::THREADS_PENDING_REQUESTS_URL;
$url = str_replace('{limit}', $limit, $url);
$url = str_replace('{cursor}', $cursor, $url);
return $url;
}
public static function getThreadsApproveMultipleUrl()
{
return static::THREADS_APPROVE_MULTIPLE_URL;
}
}