-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexamples.php
544 lines (483 loc) · 17.8 KB
/
examples.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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<?php
require('src/RocketAPI.php');
require('src/Exceptions/NotFoundException.php');
require('src/Exceptions/BadResponseException.php');
require('src/InstagramAPI.php');
use RocketAPI\InstagramAPI;
$api = new InstagramAPI("put your token here");
// ===== SEARCH METHODS =====
// Search for users
try {
echo "\n=== Search Users ===\n";
$results = $api->searchUsers('nike');
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search for hashtags
try {
echo "\n=== Search Hashtags ===\n";
$results = $api->searchHashtags('travel');
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search for locations
try {
echo "\n=== Search Locations ===\n";
$results = $api->searchLocations('new york');
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search for audio tracks
try {
echo "\n=== Search Audios ===\n";
$results = $api->searchAudios('imagine dragons');
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search for clips
try {
echo "\n=== Search Clips ===\n";
$results = $api->searchClips('real estate');
print_r($results);
// Example with pagination
if (isset($results['reels_max_id'])) {
echo "\n=== Search Clips (Page 2) ===\n";
$max_id = $results['reels_max_id'];
$nextPageResults = $api->searchClips('real estate', $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// ===== USER METHODS =====
// Get user web profile information by username
try {
echo "\n=== Get Web Profile Info ===\n";
$username = 'kyliejenner';
$results = $api->getWebProfileInfo($username);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user information by ID
try {
echo "\n=== Get User Info By ID ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserInfoById($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user media by ID
try {
echo "\n=== Get User Media ===\n";
$user_id = '25025320'; // Example user ID
$count = 12;
$results = $api->getUserMedia($user_id, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Media (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserMedia($user_id, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user media by username
try {
echo "\n=== Get User Media By Username ===\n";
$username = 'kyliejenner';
$count = 12;
$results = $api->getUserMediaByUsername($username, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Media By Username (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserMediaByUsername($username, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user clips by ID
try {
echo "\n=== Get User Clips ===\n";
$user_id = '25025320'; // Example user ID
$count = 12;
$results = $api->getUserClips($user_id, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Clips (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserClips($user_id, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user tags
try {
echo "\n=== Get User Tags ===\n";
$user_id = '25025320'; // Example user ID
$count = 12;
$results = $api->getUserTags($user_id, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Tags (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserTags($user_id, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user following
try {
echo "\n=== Get User Following ===\n";
$user_id = '25025320'; // Example user ID
$count = 12;
$results = $api->getUserFollowing($user_id, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Following (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserFollowing($user_id, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search user following by query
try {
echo "\n=== Search User Following ===\n";
$user_id = '25025320'; // Example user ID
$query = 'john';
$results = $api->searchUserFollowing($user_id, $query);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user followers
try {
echo "\n=== Get User Followers ===\n";
$user_id = '25025320'; // Example user ID
$count = 12;
$results = $api->getUserFollowers($user_id, $count);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get User Followers (Page 2) ===\n";
$max_id = $results['next_max_id'];
$nextPageResults = $api->getUserFollowers($user_id, $count, $max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Search user followers by query
try {
echo "\n=== Search User Followers ===\n";
$user_id = '25025320'; // Example user ID
$query = 'john';
$results = $api->searchUserFollowers($user_id, $query);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user stories
try {
echo "\n=== Get User Stories ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserStories($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get stories for multiple users at once
try {
echo "\n=== Get User Stories Bulk ===\n";
$user_ids = ['25025320', '18428658']; // Example user IDs
$results = $api->getUserStoriesBulk($user_ids);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user highlights
try {
echo "\n=== Get User Highlights ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserHighlights($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user live info
try {
echo "\n=== Get User Live ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserLive($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get similar accounts to user
try {
echo "\n=== Get User Similar Accounts ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserSimilarAccounts($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get user about info
try {
echo "\n=== Get User About ===\n";
$user_id = '25025320'; // Example user ID
$results = $api->getUserAbout($user_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// ===== MEDIA METHODS =====
// Get media info by ID
try {
echo "\n=== Get Media Info ===\n";
$media_id = '3615001108693103689'; // Example media ID
$results = $api->getMediaInfo($media_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media info by shortcode
try {
echo "\n=== Get Media Info By Shortcode ===\n";
$shortcode = 'DIrEFryS7RJ'; // Example shortcode
$results = $api->getMediaInfoByShortcode($shortcode);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media likes by shortcode
try {
echo "\n=== Get Media Likes By Shortcode ===\n";
$shortcode = 'DIrEFryS7RJ'; // Example shortcode
$results = $api->getMediaLikesByShortcode($shortcode);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media likes by ID
try {
echo "\n=== Get Media Likes By ID ===\n";
$media_id = '3615001108693103689'; // Example media ID
$results = $api->getMediaLikesById($media_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media comments
try {
echo "\n=== Get Media Comments ===\n";
$media_id = '3615001108693103689'; // Example media ID
$can_support_threading = true;
$results = $api->getMediaComments($media_id, $can_support_threading);
print_r($results);
// Example with pagination
if (isset($results['min_id'])) {
echo "\n=== Get Media Comments (Page 2) ===\n";
$min_id = $results['min_id'];
$nextPageResults = $api->getMediaComments($media_id, $can_support_threading, $min_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media shortcode by ID
try {
echo "\n=== Get Media Shortcode By ID ===\n";
$media_id = '3615001108693103689'; // Example media ID
$results = $api->getMediaShortcodeById($media_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media ID by shortcode
try {
echo "\n=== Get Media ID By Shortcode ===\n";
$shortcode = 'DIrEFryS7RJ'; // Example shortcode
$results = $api->getMediaIdByShortcode($shortcode);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get media ID by share code
try {
echo "\n=== Get Media ID By Share ===\n";
$share_code = '_sXbUiogP'; // Example share code
$results = $api->getMediaIdByShare($share_code);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// ===== HASHTAG, LOCATION, GUIDE METHODS =====
// Get hashtag info
try {
echo "\n=== Get Hashtag Info ===\n";
$hashtag = 'travel'; // Example hashtag (without #)
$results = $api->getHashtagInfo($hashtag);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get hashtag media
try {
echo "\n=== Get Hashtag Media ===\n";
$hashtag = 'travel'; // Example hashtag (without #)
$page = null;
$max_id = null;
$tab = 'recent'; // Options: recent, top, clips
$results = $api->getHashtagMedia($hashtag, $page, $max_id, $tab);
print_r($results);
// Example with pagination
if (isset($results['next_page']) && isset($results['next_max_id'])) {
echo "\n=== Get Hashtag Media (Page 2) ===\n";
$next_page = $results['next_page'];
$next_max_id = $results['next_max_id'];
$nextPageResults = $api->getHashtagMedia($hashtag, $next_page, $next_max_id, $tab);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get location info
try {
echo "\n=== Get Location Info ===\n";
$location_id = '212988663'; // Example location id
$results = $api->getLocationInfo($location_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get location media
try {
echo "\n=== Get Location Media ===\n";
$location_id = '212988663'; // Example location id
$page = null;
$max_id = null;
$tab = 'recent'; // Options: recent, top
$results = $api->getLocationMedia($location_id, $page, $max_id, $tab);
print_r($results);
// Example with pagination
if (isset($results['next_page']) && isset($results['next_max_id'])) {
echo "\n=== Get Location Media (Page 2) ===\n";
$next_page = $results['next_page'];
$next_max_id = $results['next_max_id'];
$nextPageResults = $api->getLocationMedia($location_id, $next_page, $next_max_id, $tab);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// ===== HIGHLIGHT, COMMENT, AUDIO METHODS =====
// Get highlight stories (note: requires a valid highlight ID)
try {
echo "\n=== Get Highlight Stories ===\n";
$highlight_id = '17946349633565357'; // Example highlight ID - you need to get this from getUserHighlights
$results = $api->getHighlightStories($highlight_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get multiple highlights at once
try {
echo "\n=== Get Highlight Stories Bulk ===\n";
$highlight_ids = ['17946349633565357', '17873483110906121']; // Example highlight IDs
$results = $api->getHighlightStoriesBulk($highlight_ids);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get comment likes
try {
echo "\n=== Get Comment Likes ===\n";
$comment_id = '18098497840546757'; // Example comment ID
$results = $api->getCommentLikes($comment_id);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get Comment Likes (Page 2) ===\n";
$next_max_id = $results['next_max_id'];
$nextPageResults = $api->getCommentLikes($comment_id, $next_max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get comment replies
try {
echo "\n=== Get Comment Replies ===\n";
$comment_id = '18098497840546757'; // Example comment ID
$media_id = '3615001108693103689'; // Example media ID
$results = $api->getCommentReplies($comment_id, $media_id);
print_r($results);
// Example with pagination
if (isset($results['next_max_child_cursor'])) {
echo "\n=== Get Comment Replies (Page 2) ===\n";
$next_max_child_cursor = $results['next_max_child_cursor'];
$nextPageResults = $api->getCommentReplies($comment_id, $media_id, $next_max_child_cursor);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get audio media
try {
echo "\n=== Get Audio Media ===\n";
$audio_id = '953905166868649'; // Example audio ID
$results = $api->getAudioMedia($audio_id);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get Audio Media (Page 2) ===\n";
$next_max_id = $results['next_max_id'];
$nextPageResults = $api->getAudioMedia($audio_id, $next_max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get audio media by canonical id
try {
echo "\n=== Get Audio Media By Canonical ID ===\n";
$audio_canonical_id = '18332183866113637'; // Example canonical ID
$results = $api->getAudioMediaByCanonicalId($audio_canonical_id);
print_r($results);
// Example with pagination
if (isset($results['next_max_id'])) {
echo "\n=== Get Audio Media By Canonical ID (Page 2) ===\n";
$next_max_id = $results['next_max_id'];
$nextPageResults = $api->getAudioMediaByCanonicalId($audio_canonical_id, $next_max_id);
print_r($nextPageResults);
}
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
// Get live info (note: requires a valid broadcast id)
try {
echo "\n=== Get Live Info ===\n";
$broadcast_id = '18033634542295083'; // Example broadcast id
$results = $api->getLiveInfo($broadcast_id);
print_r($results);
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}