Skip to content

Commit 15007af

Browse files
committed
1.0.1
1 parent 442dfff commit 15007af

File tree

7 files changed

+46
-40
lines changed

7 files changed

+46
-40
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ curl -sS https://getcomposer.org/installer | php
1212
```
1313

1414
Next, run the Composer command to install the RocketAPI PHP Library:
15+
1516
```bash
1617
composer require rocketapi/rocketapi
1718
```
1819

1920
After installing, you need to require Composer's autoloader:
21+
2022
```php
2123
require 'vendor/autoload.php';
2224
use RocketAPI\InstagramAPI;

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rocketapi/rocketapi",
33
"description": "RocketAPI PHP SDK",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"license": "MIT",
66
"authors": [
77
{

examples.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
require('src/RocketAPI.php');
3-
require('src/Exceptions.php');
3+
require('src/Exceptions/NotFoundException.php');
4+
require('src/Exceptions/BadResponseException.php');
45
require('src/InstagramAPI.php');
56

67
use RocketAPI\InstagramAPI;
@@ -12,8 +13,8 @@
1213
try {
1314
$user = $api->getUserInfo($username);
1415
print_r($user);
15-
} catch (RocketAPI\NotFoundException $e) {
16+
} catch (RocketAPI\Exceptions\NotFoundException $e) {
1617
echo "User $username not found\n";
17-
} catch (RocketAPI\BadResponseException $e) {
18+
} catch (RocketAPI\Exceptions\BadResponseException $e) {
1819
echo "Can't get $username info from API\n";
1920
}

src/Exceptions.php

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
namespace RocketAPI\Exceptions;
3+
4+
class BadResponseException extends \Exception {}

src/Exceptions/NotFoundException.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
namespace RocketAPI\Exceptions;
3+
4+
class NotFoundException extends \Exception {}

src/InstagramAPI.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public function __construct($token)
88
}
99

1010
/**
11-
* @throws NotFoundException
12-
* @throws BadResponseException
11+
* @throws Exceptions\NotFoundException
12+
* @throws Exceptions\BadResponseException
1313
*/
1414
protected function request($method, $data)
1515
{
@@ -18,18 +18,18 @@ protected function request($method, $data)
1818
if ($response['response']['status_code'] == 200 && $response['response']['content_type'] == 'application/json') {
1919
return $response['response']['body'];
2020
} else if ($response['response']['status_code'] == 404) {
21-
throw new NotFoundException('Instagram resource not found');
21+
throw new Exceptions\NotFoundException('Instagram resource not found');
2222
} else {
23-
throw new BadResponseException('Bad response from Instagram');
23+
throw new Exceptions\BadResponseException('Bad response from Instagram');
2424
}
2525
} else {
26-
throw new BadResponseException('Bad response from RocketAPI');
26+
throw new Exceptions\BadResponseException('Bad response from RocketAPI');
2727
}
2828
}
2929

3030
/**
31-
* @throws NotFoundException
32-
* @throws BadResponseException
31+
* @throws Exceptions\NotFoundException
32+
* @throws Exceptions\BadResponseException
3333
*/
3434
public function search($query) {
3535
return $this->request('instagram/search', [
@@ -38,8 +38,8 @@ public function search($query) {
3838
}
3939

4040
/**
41-
* @throws NotFoundException
42-
* @throws BadResponseException
41+
* @throws Exceptions\NotFoundException
42+
* @throws Exceptions\BadResponseException
4343
*/
4444
public function getUserInfo($username) {
4545
return $this->request('instagram/user/get_info', [
@@ -48,8 +48,8 @@ public function getUserInfo($username) {
4848
}
4949

5050
/**
51-
* @throws NotFoundException
52-
* @throws BadResponseException
51+
* @throws Exceptions\NotFoundException
52+
* @throws Exceptions\BadResponseException
5353
*/
5454
public function getUserInfoById($user_id) {
5555
return $this->request('instagram/user/get_info_by_id', [
@@ -58,8 +58,8 @@ public function getUserInfoById($user_id) {
5858
}
5959

6060
/**
61-
* @throws NotFoundException
62-
* @throws BadResponseException
61+
* @throws Exceptions\NotFoundException
62+
* @throws Exceptions\BadResponseException
6363
*/
6464
public function getUserMedia($user_id, $count=12, $max_id=null) {
6565
$payload = ['id' => $user_id, 'count' => $count];
@@ -70,8 +70,8 @@ public function getUserMedia($user_id, $count=12, $max_id=null) {
7070
}
7171

7272
/**
73-
* @throws NotFoundException
74-
* @throws BadResponseException
73+
* @throws Exceptions\NotFoundException
74+
* @throws Exceptions\BadResponseException
7575
*/
7676
public function getUserFollowing($user_id, $count=12, $max_id=null) {
7777
$payload = ['id' => $user_id, 'count' => $count];
@@ -82,8 +82,8 @@ public function getUserFollowing($user_id, $count=12, $max_id=null) {
8282
}
8383

8484
/**
85-
* @throws NotFoundException
86-
* @throws BadResponseException
85+
* @throws Exceptions\NotFoundException
86+
* @throws Exceptions\BadResponseException
8787
*/
8888
public function getUserFollowers($user_id, $count=12, $max_id=null)
8989
{
@@ -95,8 +95,8 @@ public function getUserFollowers($user_id, $count=12, $max_id=null)
9595
}
9696

9797
/**
98-
* @throws NotFoundException
99-
* @throws BadResponseException
98+
* @throws Exceptions\NotFoundException
99+
* @throws Exceptions\BadResponseException
100100
*/
101101
public function searchUserFollowers($user_id, $query) {
102102
return $this->request('instagram/user/get_followers', [
@@ -106,8 +106,8 @@ public function searchUserFollowers($user_id, $query) {
106106
}
107107

108108
/**
109-
* @throws NotFoundException
110-
* @throws BadResponseException
109+
* @throws Exceptions\NotFoundException
110+
* @throws Exceptions\BadResponseException
111111
*/
112112
public function getUserStoriesBulk($user_ids) {
113113
return $this->request('instagram/user/get_stories', [
@@ -116,16 +116,16 @@ public function getUserStoriesBulk($user_ids) {
116116
}
117117

118118
/**
119-
* @throws NotFoundException
120-
* @throws BadResponseException
119+
* @throws Exceptions\NotFoundException
120+
* @throws Exceptions\BadResponseException
121121
*/
122122
public function getUserStories($user_id) {
123123
return $this->getUserStoriesBulk([$user_id]);
124124
}
125125

126126
/**
127-
* @throws NotFoundException
128-
* @throws BadResponseException
127+
* @throws Exceptions\NotFoundException
128+
* @throws Exceptions\BadResponseException
129129
*/
130130
public function getMediaInfo($media_id) {
131131
return $this->request('instagram/media/get_info', [
@@ -134,8 +134,8 @@ public function getMediaInfo($media_id) {
134134
}
135135

136136
/**
137-
* @throws NotFoundException
138-
* @throws BadResponseException
137+
* @throws Exceptions\NotFoundException
138+
* @throws Exceptions\BadResponseException
139139
*/
140140
public function getMediaLikes($shortcode, $count=12, $max_id=null) {
141141
$payload = ['shortcode' => $shortcode, 'count' => $count];
@@ -146,8 +146,8 @@ public function getMediaLikes($shortcode, $count=12, $max_id=null) {
146146
}
147147

148148
/**
149-
* @throws NotFoundException
150-
* @throws BadResponseException
149+
* @throws Exceptions\NotFoundException
150+
* @throws Exceptions\BadResponseException
151151
*/
152152
public function getMediaComments($media_id, $can_support_threading=true, $min_id=null) {
153153
$payload = ['id' => $media_id, 'can_support_threading' => $can_support_threading];
@@ -158,8 +158,8 @@ public function getMediaComments($media_id, $can_support_threading=true, $min_id
158158
}
159159

160160
/**
161-
* @throws NotFoundException
162-
* @throws BadResponseException
161+
* @throws Exceptions\NotFoundException
162+
* @throws Exceptions\BadResponseException
163163
*/
164164
public function getCommentLikes($comment_id, $max_id=null) {
165165
$payload = ['id' => $comment_id];

0 commit comments

Comments
 (0)