@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * @param \Http\Client\HttpClient|null $httpClient |
41 | 41 | * @param \Http\Message\RequestFactory|null $requestFactory |
42 | 42 | */ |
43 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
43 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
44 | 44 | { |
45 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
45 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
46 | 46 | |
47 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
47 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $token |
54 | 54 | */ |
55 | - public function setToken ( string $token ) |
|
55 | + public function setToken(string $token) |
|
56 | 56 | { |
57 | - $this->accessToken = new AccessToken ( $token ); |
|
57 | + $this->accessToken = new AccessToken($token); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return object AccessToken |
64 | 64 | */ |
65 | - public function getToken () : AccessToken |
|
65 | + public function getToken() : AccessToken |
|
66 | 66 | { |
67 | 67 | return $this->accessToken; |
68 | 68 | } |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function infoLocation ( LocationId $locationId ) : array |
|
75 | + public function infoLocation(LocationId $locationId) : array |
|
76 | 76 | { |
77 | - if ( false == ( $locationId instanceof LocationId ) ) |
|
77 | + if (false == ($locationId instanceof LocationId)) |
|
78 | 78 | { |
79 | - throw new LocationException ( "Current param isn't instance of LocationId." ); |
|
79 | + throw new LocationException("Current param isn't instance of LocationId."); |
|
80 | 80 | } |
81 | 81 | |
82 | - $uri = sprintf ( "https://api.instagram.com/v1/locations/%s?access_token=%s", $locationId, $this->accessToken ); |
|
82 | + $uri = sprintf("https://api.instagram.com/v1/locations/%s?access_token=%s", $locationId, $this->accessToken); |
|
83 | 83 | |
84 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
84 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
85 | 85 | |
86 | - $response = $this->httpClient->sendRequest ( $request ); |
|
86 | + $response = $this->httpClient->sendRequest($request); |
|
87 | 87 | |
88 | - if ( $response->getStatusCode () === 400 ) |
|
88 | + if ($response->getStatusCode() === 400) |
|
89 | 89 | { |
90 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
90 | + $body = json_decode(( string ) $response->getBody()); |
|
91 | 91 | |
92 | - throw new LocationException ( $body->meta->error_message ); |
|
92 | + throw new LocationException($body->meta->error_message); |
|
93 | 93 | } |
94 | 94 | |
95 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
95 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,27 +100,27 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return array |
102 | 102 | */ |
103 | - public function listMediaLocation ( LocationId $locationId ) : array |
|
103 | + public function listMediaLocation(LocationId $locationId) : array |
|
104 | 104 | { |
105 | - if ( false == ( $locationId instanceof LocationId ) ) |
|
105 | + if (false == ($locationId instanceof LocationId)) |
|
106 | 106 | { |
107 | - throw new LocationException ( "Current param isn't instce of LocationId." ); |
|
107 | + throw new LocationException("Current param isn't instce of LocationId."); |
|
108 | 108 | } |
109 | 109 | |
110 | - $uri = sprintf ( "https://api.instagram.com/v1/locations/%s/media/recent?access_token=%s", $locationId, $this->accessToken ); |
|
110 | + $uri = sprintf("https://api.instagram.com/v1/locations/%s/media/recent?access_token=%s", $locationId, $this->accessToken); |
|
111 | 111 | |
112 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
112 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
113 | 113 | |
114 | - $response = $this->httpClient->sendRequest ( $request ); |
|
114 | + $response = $this->httpClient->sendRequest($request); |
|
115 | 115 | |
116 | - if ( $response->getStatusCode () === 400 ) |
|
116 | + if ($response->getStatusCode() === 400) |
|
117 | 117 | { |
118 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
118 | + $body = json_decode(( string ) $response->getBody()); |
|
119 | 119 | |
120 | - throw new LocationException ( $body->meta->error_message ); |
|
120 | + throw new LocationException($body->meta->error_message); |
|
121 | 121 | } |
122 | 122 | |
123 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
123 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -128,26 +128,26 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public function searchLocation ( Map $map ) : array |
|
131 | + public function searchLocation(Map $map) : array |
|
132 | 132 | { |
133 | - if ( false == ( $map instanceof Map ) ) |
|
133 | + if (false == ($map instanceof Map)) |
|
134 | 134 | { |
135 | - throw new LocationException ( "Current param isn't instance of Map." ); |
|
135 | + throw new LocationException("Current param isn't instance of Map."); |
|
136 | 136 | } |
137 | 137 | |
138 | - $uri = sprintf ( "https://api.instagram.com/v1/locations/search?lat=%s&lng=%s&distance=%s&access_token=%s", $map->getLat (), $map->getLng (), $map->getDistance (), $this->accessToken ); |
|
138 | + $uri = sprintf("https://api.instagram.com/v1/locations/search?lat=%s&lng=%s&distance=%s&access_token=%s", $map->getLat(), $map->getLng(), $map->getDistance(), $this->accessToken); |
|
139 | 139 | |
140 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
140 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
141 | 141 | |
142 | - $response = $this->httpClient->sendRequest ( $request ); |
|
142 | + $response = $this->httpClient->sendRequest($request); |
|
143 | 143 | |
144 | - if ( $response->getStatusCode () === 400 ) |
|
144 | + if ($response->getStatusCode() === 400) |
|
145 | 145 | { |
146 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
146 | + $body = json_decode(( string ) $response->getBody()); |
|
147 | 147 | |
148 | - throw new LocationException ( $body->meta->error_message ); |
|
148 | + throw new LocationException($body->meta->error_message); |
|
149 | 149 | } |
150 | 150 | |
151 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
151 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param \Http\Client\HttpClient|null $httpClient |
66 | 66 | * @param \Http\Message\RequestFactory|null $requestFactory |
67 | 67 | */ |
68 | - public function __construct ( string $appId, string $appSecret, string $appCallback, HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
68 | + public function __construct(string $appId, string $appSecret, string $appCallback, HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
69 | 69 | { |
70 | 70 | $this->appId = ( string ) $appId; |
71 | 71 | |
@@ -73,24 +73,24 @@ discard block |
||
73 | 73 | |
74 | 74 | $this->appCallback = ( string ) $appCallback; |
75 | 75 | |
76 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
76 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
77 | 77 | |
78 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
78 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Get URL Login redirect Instagram |
83 | 83 | */ |
84 | - public function getLogin () : string |
|
84 | + public function getLogin() : string |
|
85 | 85 | { |
86 | - if ( empty ( $this->appId ) ) |
|
86 | + if (empty ($this->appId)) |
|
87 | 87 | { |
88 | - throw new LoginException ( "AppID required." ); |
|
88 | + throw new LoginException("AppID required."); |
|
89 | 89 | } |
90 | 90 | |
91 | - if ( empty ( $this->appScope ) ) |
|
91 | + if (empty ($this->appScope)) |
|
92 | 92 | { |
93 | - throw new LoginException ( "AppScope required." ); |
|
93 | + throw new LoginException("AppScope required."); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return "https://api.instagram.com/oauth/authorize/?client_id=" . $this->appId . "&redirect_uri" . $this->appCallback . "&response_type=code" . "&scope=" . $this->appScope; |
@@ -101,34 +101,34 @@ discard block |
||
101 | 101 | * |
102 | 102 | * param string $code |
103 | 103 | */ |
104 | - public function doAuth ( string $code ) : array |
|
104 | + public function doAuth(string $code) : array |
|
105 | 105 | { |
106 | - if ( empty ( $code ) ) |
|
106 | + if (empty ($code)) |
|
107 | 107 | { |
108 | - throw new LoginException ( "Code required." ); |
|
108 | + throw new LoginException("Code required."); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $uri = "https://api.instagram.com/oauth/access_token"; |
112 | 112 | |
113 | - $this->builder->addResource ( "client_id", $this->appId ); |
|
114 | - $this->builder->addResource ( "client_secret", $this->appSecret ); |
|
115 | - $this->builder->addResource ( "grant_type", "authorization_code" ); |
|
116 | - $this->builder->addResource ( "redirect_uri", $this->appCallback ); |
|
117 | - $this->builder->addResource ( "code", $code ); |
|
113 | + $this->builder->addResource("client_id", $this->appId); |
|
114 | + $this->builder->addResource("client_secret", $this->appSecret); |
|
115 | + $this->builder->addResource("grant_type", "authorization_code"); |
|
116 | + $this->builder->addResource("redirect_uri", $this->appCallback); |
|
117 | + $this->builder->addResource("code", $code); |
|
118 | 118 | |
119 | - $request = $this->requestFactory->createRequest ( "POST", $uri, [ |
|
120 | - "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary () . '"' |
|
121 | - ], ( string ) $this->builder->build () ); |
|
119 | + $request = $this->requestFactory->createRequest("POST", $uri, [ |
|
120 | + "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary() . '"' |
|
121 | + ], ( string ) $this->builder->build()); |
|
122 | 122 | |
123 | - $response = $this->httpClient->sendRequest ( $request ); |
|
123 | + $response = $this->httpClient->sendRequest($request); |
|
124 | 124 | |
125 | - if ( $response->getStatusCode () === 400 ) |
|
125 | + if ($response->getStatusCode() === 400) |
|
126 | 126 | { |
127 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
127 | + $body = json_decode(( string ) $response->getBody()); |
|
128 | 128 | |
129 | - throw new LoginException ( $body->meta->error_message ); |
|
129 | + throw new LoginException($body->meta->error_message); |
|
130 | 130 | } |
131 | 131 | |
132 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
132 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * @param \Http\Client\HttpClient|null $httpClient |
41 | 41 | * @param \Http\Message\RequestFactory|null $requestFactory |
42 | 42 | */ |
43 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
43 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
44 | 44 | { |
45 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
45 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
46 | 46 | |
47 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
47 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string $token |
54 | 54 | */ |
55 | - public function setToken ( $token ) |
|
55 | + public function setToken($token) |
|
56 | 56 | { |
57 | - $this->accessToken = new AccessToken ( $token ); |
|
57 | + $this->accessToken = new AccessToken($token); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return object Access Token |
64 | 64 | */ |
65 | - public function getToken () : AccessToken |
|
65 | + public function getToken() : AccessToken |
|
66 | 66 | { |
67 | 67 | return $this->accessToken; |
68 | 68 | } |
@@ -72,22 +72,22 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function getSelf () : array |
|
75 | + public function getSelf() : array |
|
76 | 76 | { |
77 | - $uri = sprintf ( "https://api.instagram.com/v1/users/self/?access_token=%s", $this->accessToken ); |
|
77 | + $uri = sprintf("https://api.instagram.com/v1/users/self/?access_token=%s", $this->accessToken); |
|
78 | 78 | |
79 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
79 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
80 | 80 | |
81 | - $response = $this->httpClient->sendRequest ( $request ); |
|
81 | + $response = $this->httpClient->sendRequest($request); |
|
82 | 82 | |
83 | - if ( $response->getStatusCode () === 400 ) |
|
83 | + if ($response->getStatusCode() === 400) |
|
84 | 84 | { |
85 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
85 | + $body = json_decode(( string ) $response->getBody()); |
|
86 | 86 | |
87 | - throw new UserException ( $body->meta->error_message ); |
|
87 | + throw new UserException($body->meta->error_message); |
|
88 | 88 | } |
89 | 89 | |
90 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
90 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,27 +95,27 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return array |
97 | 97 | */ |
98 | - public function getInfo ( UserId $userId ) : array |
|
98 | + public function getInfo(UserId $userId) : array |
|
99 | 99 | { |
100 | - if ( false == ( $userId instanceof UserId ) ) |
|
100 | + if (false == ($userId instanceof UserId)) |
|
101 | 101 | { |
102 | - throw new UserException ( "Current param isn't instance of UserId." ); |
|
102 | + throw new UserException("Current param isn't instance of UserId."); |
|
103 | 103 | } |
104 | 104 | |
105 | - $uri = sprintf ( "https://api.instagram.com/v1/users/%s/?access_token=%s", ( string ) $this->userId->__toInt(), $this->accessToken ); |
|
105 | + $uri = sprintf("https://api.instagram.com/v1/users/%s/?access_token=%s", ( string ) $this->userId->__toInt(), $this->accessToken); |
|
106 | 106 | |
107 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
107 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
108 | 108 | |
109 | - $response = $this->httpClient->sendRequest ( $request ); |
|
109 | + $response = $this->httpClient->sendRequest($request); |
|
110 | 110 | |
111 | - if ( $response->getStatusCode () === 400 ) |
|
111 | + if ($response->getStatusCode() === 400) |
|
112 | 112 | { |
113 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
113 | + $body = json_decode(( string ) $response->getBody()); |
|
114 | 114 | |
115 | - throw new UserException ( $body->meta->error_message ); |
|
115 | + throw new UserException($body->meta->error_message); |
|
116 | 116 | } |
117 | 117 | |
118 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
118 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - public function getMedia () : array |
|
126 | + public function getMedia() : array |
|
127 | 127 | { |
128 | - $uri = sprintf ( "https://api.instagram.com/v1/users/self/media/recent?access_token=%s", $this->accessToken ); |
|
128 | + $uri = sprintf("https://api.instagram.com/v1/users/self/media/recent?access_token=%s", $this->accessToken); |
|
129 | 129 | |
130 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
130 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
131 | 131 | |
132 | - $response = $this->httpClient->sendRequest ( $request ); |
|
132 | + $response = $this->httpClient->sendRequest($request); |
|
133 | 133 | |
134 | - if ( $response->getStatusCode () === 400 ) |
|
134 | + if ($response->getStatusCode() === 400) |
|
135 | 135 | { |
136 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
136 | + $body = json_decode(( string ) $response->getBody()); |
|
137 | 137 | |
138 | - throw new UserException ( $body->meta->error_message ); |
|
138 | + throw new UserException($body->meta->error_message); |
|
139 | 139 | } |
140 | 140 | |
141 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
141 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return array |
148 | 148 | */ |
149 | - public function getLiked () : array |
|
149 | + public function getLiked() : array |
|
150 | 150 | { |
151 | - $uri = sprintf ( "https://api.instagram.com/v1/users/self/media/liked?access_token=%s", $this->accessToken ); |
|
151 | + $uri = sprintf("https://api.instagram.com/v1/users/self/media/liked?access_token=%s", $this->accessToken); |
|
152 | 152 | |
153 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
153 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
154 | 154 | |
155 | - $response = $this->httpClient->sendRequest ( $request ); |
|
155 | + $response = $this->httpClient->sendRequest($request); |
|
156 | 156 | |
157 | - if ( $response->getStatusCode () === 400 ) |
|
157 | + if ($response->getStatusCode() === 400) |
|
158 | 158 | { |
159 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
159 | + $body = json_decode(( string ) $response->getBody()); |
|
160 | 160 | |
161 | - throw new UserException ( $body->meta->error_message ); |
|
161 | + throw new UserException($body->meta->error_message); |
|
162 | 162 | } |
163 | 163 | |
164 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
164 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -170,27 +170,27 @@ discard block |
||
170 | 170 | * @param object Name $name |
171 | 171 | * @return array |
172 | 172 | */ |
173 | - public function searchUser ( Name $name ) : array |
|
173 | + public function searchUser(Name $name) : array |
|
174 | 174 | { |
175 | - if ( false == ( $name instanceof Name ) ) |
|
175 | + if (false == ($name instanceof Name)) |
|
176 | 176 | { |
177 | - throw new UserException ( "Current param isn't instance of Name Class." ); |
|
177 | + throw new UserException("Current param isn't instance of Name Class."); |
|
178 | 178 | } |
179 | 179 | |
180 | - $uri = sprintf ( "https://api.instagram.com/v1/users/search?q=%s&access_token=%s", $name->__toString (), $this->accessToken ); |
|
180 | + $uri = sprintf("https://api.instagram.com/v1/users/search?q=%s&access_token=%s", $name->__toString(), $this->accessToken); |
|
181 | 181 | |
182 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
182 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
183 | 183 | |
184 | - $response = $this->httpClient->sendRequest ( $request ); |
|
184 | + $response = $this->httpClient->sendRequest($request); |
|
185 | 185 | |
186 | - if ( $response->getStatusCode () === 400 ) |
|
186 | + if ($response->getStatusCode() === 400) |
|
187 | 187 | { |
188 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
188 | + $body = json_decode(( string ) $response->getBody()); |
|
189 | 189 | |
190 | - throw new UserException ( $body->meta->error_message ); |
|
190 | + throw new UserException($body->meta->error_message); |
|
191 | 191 | } |
192 | 192 | |
193 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
193 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -198,26 +198,26 @@ discard block |
||
198 | 198 | * |
199 | 199 | * @return array |
200 | 200 | */ |
201 | - public function readUserMedia ( UserId $userId ) : array |
|
201 | + public function readUserMedia(UserId $userId) : array |
|
202 | 202 | { |
203 | - if ( false == ( $userId instanceof UserId ) ) |
|
203 | + if (false == ($userId instanceof UserId)) |
|
204 | 204 | { |
205 | - throw new UserException ( "Current param isn't instance of UserId Class." ); |
|
205 | + throw new UserException("Current param isn't instance of UserId Class."); |
|
206 | 206 | } |
207 | 207 | |
208 | - $uri = sprintf ( "https://api.instagram.com/v1/users/%s/media/recent/?access_token=%s", $userId->__toInt (), $this->accessToken ); |
|
208 | + $uri = sprintf("https://api.instagram.com/v1/users/%s/media/recent/?access_token=%s", $userId->__toInt(), $this->accessToken); |
|
209 | 209 | |
210 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
210 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
211 | 211 | |
212 | - $response = $this->httpClient->sendRequest ( $request ); |
|
212 | + $response = $this->httpClient->sendRequest($request); |
|
213 | 213 | |
214 | - if ( $response->getStatusCode () === 400 ) |
|
214 | + if ($response->getStatusCode() === 400) |
|
215 | 215 | { |
216 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
216 | + $body = json_decode(( string ) $response->getBody()); |
|
217 | 217 | |
218 | - throw new UserException ( $body->meta->error_message ); |
|
218 | + throw new UserException($body->meta->error_message); |
|
219 | 219 | } |
220 | 220 | |
221 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
221 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
222 | 222 | } |
223 | 223 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * @param \Http\Client\HttpClient|null $httpClient |
41 | 41 | * @param \Http\Message\RequestFactory|null $requestFactory |
42 | 42 | */ |
43 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
43 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
44 | 44 | { |
45 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
45 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
46 | 46 | |
47 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
47 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @param string accessToken |
54 | 54 | */ |
55 | - public function setToken ( string $token ) |
|
55 | + public function setToken(string $token) |
|
56 | 56 | { |
57 | - $this->accessToken = new AccessToken ( $token ); |
|
57 | + $this->accessToken = new AccessToken($token); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return object AccessToken |
64 | 64 | */ |
65 | - public function getToken () : AccessToken |
|
65 | + public function getToken() : AccessToken |
|
66 | 66 | { |
67 | 67 | return $this->accessToken; |
68 | 68 | } |
@@ -72,27 +72,27 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - public function readMedia ( MediaId $mediaId ) : array |
|
75 | + public function readMedia(MediaId $mediaId) : array |
|
76 | 76 | { |
77 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
77 | + if (false == ($mediaId instanceof MediaId)) |
|
78 | 78 | { |
79 | - throw new MediaException ( "Current param isn't Instance of MediaId" ); |
|
79 | + throw new MediaException("Current param isn't Instance of MediaId"); |
|
80 | 80 | } |
81 | 81 | |
82 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s?access_token=%s", $mediaId, $this->accessToken ); |
|
82 | + $uri = sprintf("https://api.instagram.com/v1/media/%s?access_token=%s", $mediaId, $this->accessToken); |
|
83 | 83 | |
84 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
84 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
85 | 85 | |
86 | - $response = $this->httpClient->sendRequest ( $request ); |
|
86 | + $response = $this->httpClient->sendRequest($request); |
|
87 | 87 | |
88 | - if ( $response->getStatusCode () === 400 ) |
|
88 | + if ($response->getStatusCode() === 400) |
|
89 | 89 | { |
90 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
90 | + $body = json_decode(( string ) $response->getBody()); |
|
91 | 91 | |
92 | - throw new MediaException ( $body->meta->error_message ); |
|
92 | + throw new MediaException($body->meta->error_message); |
|
93 | 93 | } |
94 | 94 | |
95 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
95 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,27 +100,27 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return array |
102 | 102 | */ |
103 | - public function infoMedia ( ShortCode $shortCode ) : array |
|
103 | + public function infoMedia(ShortCode $shortCode) : array |
|
104 | 104 | { |
105 | - if ( false == ( $shortCode instanceof ShortCode ) ) |
|
105 | + if (false == ($shortCode instanceof ShortCode)) |
|
106 | 106 | { |
107 | - throw new MediaException ( "Current param isn't Instance Of ShortCode." ); |
|
107 | + throw new MediaException("Current param isn't Instance Of ShortCode."); |
|
108 | 108 | } |
109 | 109 | |
110 | - $uri = sprintf ( "https://api.instagram.com/v1/media/shortcode/%s?access_token=%s", $shortCode, $this->accessToken ); |
|
110 | + $uri = sprintf("https://api.instagram.com/v1/media/shortcode/%s?access_token=%s", $shortCode, $this->accessToken); |
|
111 | 111 | |
112 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
112 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
113 | 113 | |
114 | - $response = $this->httpClient->sendRequest ( $request ); |
|
114 | + $response = $this->httpClient->sendRequest($request); |
|
115 | 115 | |
116 | - if ( $response->getStatusCode () === 400 ) |
|
116 | + if ($response->getStatusCode() === 400) |
|
117 | 117 | { |
118 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
118 | + $body = json_decode(( string ) $response->getBody()); |
|
119 | 119 | |
120 | - throw new MediaException ( $body->meta->error_message ); |
|
120 | + throw new MediaException($body->meta->error_message); |
|
121 | 121 | } |
122 | 122 | |
123 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
123 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -128,26 +128,26 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return array |
130 | 130 | */ |
131 | - public function searchMedia ( Map $map ) : array |
|
131 | + public function searchMedia(Map $map) : array |
|
132 | 132 | { |
133 | - if ( false == ( $map instanceof Map ) ) |
|
133 | + if (false == ($map instanceof Map)) |
|
134 | 134 | { |
135 | - throw new MediaException ( "Current param isn't Instance of Map." ); |
|
135 | + throw new MediaException("Current param isn't Instance of Map."); |
|
136 | 136 | } |
137 | 137 | |
138 | - $uri = sprintf ( "https://api.instagram.com/v1/media/search?lat=%s&lng=%s&distance=%s&access_token=%s", $map->getLat (), $map->getLng (), $map->getDistance (), $this->accessToken ); |
|
138 | + $uri = sprintf("https://api.instagram.com/v1/media/search?lat=%s&lng=%s&distance=%s&access_token=%s", $map->getLat(), $map->getLng(), $map->getDistance(), $this->accessToken); |
|
139 | 139 | |
140 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
140 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
141 | 141 | |
142 | - $response = $this->httpClient->sendRequest ( $request ); |
|
142 | + $response = $this->httpClient->sendRequest($request); |
|
143 | 143 | |
144 | - if ( $response->getStatusCode () === 400 ) |
|
144 | + if ($response->getStatusCode() === 400) |
|
145 | 145 | { |
146 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
146 | + $body = json_decode(( string ) $response->getBody()); |
|
147 | 147 | |
148 | - throw new MediaException ( $body->meta->error_message ); |
|
148 | + throw new MediaException($body->meta->error_message); |
|
149 | 149 | } |
150 | 150 | |
151 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
151 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * @param \Http\Client\HttpClient|null $httpClient |
47 | 47 | * @param \Http\Message\RequestFactory|null $requestFactory |
48 | 48 | */ |
49 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
49 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
50 | 50 | { |
51 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
51 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
52 | 52 | |
53 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
53 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
54 | 54 | |
55 | - $this->builder = new MultipartStreamBuilder (); |
|
55 | + $this->builder = new MultipartStreamBuilder(); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $token |
62 | 62 | */ |
63 | - public function setToken ( string $token ) |
|
63 | + public function setToken(string $token) |
|
64 | 64 | { |
65 | - $this->accessToken = new AccessToken ( $token ); |
|
65 | + $this->accessToken = new AccessToken($token); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return object AccessToken |
72 | 72 | */ |
73 | - public function getToken () : AccessToken |
|
73 | + public function getToken() : AccessToken |
|
74 | 74 | { |
75 | 75 | return $this->accessToken; |
76 | 76 | } |
@@ -80,27 +80,27 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function listComment ( MediaId $mediaId ) : array |
|
83 | + public function listComment(MediaId $mediaId) : array |
|
84 | 84 | { |
85 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
85 | + if (false == ($mediaId instanceof MediaId)) |
|
86 | 86 | { |
87 | - throw new CommentException ( "Current param isn't instance of MediaId." ); |
|
87 | + throw new CommentException("Current param isn't instance of MediaId."); |
|
88 | 88 | } |
89 | 89 | |
90 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/comments?access_token=%s", ( int ) $mediaId, $this->accessToken ); |
|
90 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/comments?access_token=%s", ( int ) $mediaId, $this->accessToken); |
|
91 | 91 | |
92 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
92 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
93 | 93 | |
94 | - $response = $this->httpClient->sendRequest ( $request ); |
|
94 | + $response = $this->httpClient->sendRequest($request); |
|
95 | 95 | |
96 | - if ( $response->getStatusCode () === 400 ) |
|
96 | + if ($response->getStatusCode() === 400) |
|
97 | 97 | { |
98 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
98 | + $body = json_decode(( string ) $response->getBody()); |
|
99 | 99 | |
100 | - throw new InstagramException ( $body->meta->error_message ); |
|
100 | + throw new InstagramException($body->meta->error_message); |
|
101 | 101 | } |
102 | 102 | |
103 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
103 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -108,36 +108,36 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return array |
110 | 110 | */ |
111 | - public function sendComment ( MediaId $mediaId, string $comment ) : array |
|
111 | + public function sendComment(MediaId $mediaId, string $comment) : array |
|
112 | 112 | { |
113 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
113 | + if (false == ($mediaId instanceof MediaId)) |
|
114 | 114 | { |
115 | - throw new CommentException ( "Current param isn't instance of MediaId." ); |
|
115 | + throw new CommentException("Current param isn't instance of MediaId."); |
|
116 | 116 | } |
117 | 117 | |
118 | - if ( empty ( $comment ) ) |
|
118 | + if (empty ($comment)) |
|
119 | 119 | { |
120 | - throw new CommentException ( "Comment required." ); |
|
120 | + throw new CommentException("Comment required."); |
|
121 | 121 | } |
122 | 122 | |
123 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/comments?access_token=", $mediaId, $this->accessToken ); |
|
123 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/comments?access_token=", $mediaId, $this->accessToken); |
|
124 | 124 | |
125 | - $this->builder->addResource ( "text", $comment ); |
|
125 | + $this->builder->addResource("text", $comment); |
|
126 | 126 | |
127 | - $request = $this->requestFactory->createRequest ( "POST", $uri, [ |
|
128 | - "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary () . '"' |
|
129 | - ], ( string ) $this->builder->build () ); |
|
127 | + $request = $this->requestFactory->createRequest("POST", $uri, [ |
|
128 | + "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary() . '"' |
|
129 | + ], ( string ) $this->builder->build()); |
|
130 | 130 | |
131 | - $response = $this->httpClient->sendRequest ( $request ); |
|
131 | + $response = $this->httpClient->sendRequest($request); |
|
132 | 132 | |
133 | - if ( $response->getStatusCode () === 400 ) |
|
133 | + if ($response->getStatusCode() === 400) |
|
134 | 134 | { |
135 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
135 | + $body = json_decode(( string ) $response->getBody()); |
|
136 | 136 | |
137 | - throw new CommentException ( $body->meta->error_message ); |
|
137 | + throw new CommentException($body->meta->error_message); |
|
138 | 138 | } |
139 | 139 | |
140 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
140 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -145,31 +145,31 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return array |
147 | 147 | */ |
148 | - public function deleteComment ( MediaId $mediaId, CommentId $commentId ) : array |
|
148 | + public function deleteComment(MediaId $mediaId, CommentId $commentId) : array |
|
149 | 149 | { |
150 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
150 | + if (false == ($mediaId instanceof MediaId)) |
|
151 | 151 | { |
152 | - throw new CommentException ( "Current param isn't instance of MediaId." ); |
|
152 | + throw new CommentException("Current param isn't instance of MediaId."); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( false == ( $commentId instanceof CommentId ) ) |
|
155 | + if (false == ($commentId instanceof CommentId)) |
|
156 | 156 | { |
157 | - throw new CommentException ( "Current param isn't instance of MediaId." ); |
|
157 | + throw new CommentException("Current param isn't instance of MediaId."); |
|
158 | 158 | } |
159 | 159 | |
160 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/comments/%s?access_token=", $mediaId, $commentId, $this->accessToken ); |
|
160 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/comments/%s?access_token=", $mediaId, $commentId, $this->accessToken); |
|
161 | 161 | |
162 | - $request = $this->requestFactory->createRequest ( "DELETE", $uri ); |
|
162 | + $request = $this->requestFactory->createRequest("DELETE", $uri); |
|
163 | 163 | |
164 | - $response = $this->httpClient->sendRequest ( $request ); |
|
164 | + $response = $this->httpClient->sendRequest($request); |
|
165 | 165 | |
166 | - if ( $response->getStatusCode () === 400 ) |
|
166 | + if ($response->getStatusCode() === 400) |
|
167 | 167 | { |
168 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
168 | + $body = json_decode(( string ) $response->getBody()); |
|
169 | 169 | |
170 | - throw new CommentException ( $body->meta->error_message ); |
|
170 | + throw new CommentException($body->meta->error_message); |
|
171 | 171 | } |
172 | 172 | |
173 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
173 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * @param \Http\Client\HttpClient|null $httpClient |
45 | 45 | * @param \Http\Message\RequestFactory|null $requestFactory |
46 | 46 | */ |
47 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
47 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
48 | 48 | { |
49 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
49 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
50 | 50 | |
51 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
51 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
52 | 52 | |
53 | - $this->builder = new MultipartStreamBuilder (); |
|
53 | + $this->builder = new MultipartStreamBuilder(); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param string $token |
60 | 60 | */ |
61 | - public function setToken ( string $token ) |
|
61 | + public function setToken(string $token) |
|
62 | 62 | { |
63 | - $this->accessToken = new AccessToken ( $token ); |
|
63 | + $this->accessToken = new AccessToken($token); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @return object AccessToken |
70 | 70 | */ |
71 | - public function getToken () : AccessToken |
|
71 | + public function getToken() : AccessToken |
|
72 | 72 | { |
73 | 73 | return $this->accessToken; |
74 | 74 | } |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | * @param object MediaId $mediaId |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - public function listLike ( MediaId $mediaId ) : array |
|
82 | + public function listLike(MediaId $mediaId) : array |
|
83 | 83 | { |
84 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
84 | + if (false == ($mediaId instanceof MediaId)) |
|
85 | 85 | { |
86 | - throw new LikeException ( "Current param isn't instance of MediaId." ); |
|
86 | + throw new LikeException("Current param isn't instance of MediaId."); |
|
87 | 87 | } |
88 | 88 | |
89 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/likes?access_token=%s", $mediaId, $this->accessToken ); |
|
89 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/likes?access_token=%s", $mediaId, $this->accessToken); |
|
90 | 90 | |
91 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
91 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
92 | 92 | |
93 | - $response = $this->httpClient->sendRequest ( $request ); |
|
93 | + $response = $this->httpClient->sendRequest($request); |
|
94 | 94 | |
95 | - if ( $response->getStatusCode () === 400 ) |
|
95 | + if ($response->getStatusCode() === 400) |
|
96 | 96 | { |
97 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
97 | + $body = json_decode(( string ) $response->getBody()); |
|
98 | 98 | |
99 | - throw new LikeException ( $body->meta->error_message ); |
|
99 | + throw new LikeException($body->meta->error_message); |
|
100 | 100 | } |
101 | 101 | |
102 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
102 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
@@ -108,31 +108,31 @@ discard block |
||
108 | 108 | * @param object MediaId $mediaId |
109 | 109 | * @return array |
110 | 110 | */ |
111 | - public function sendLike ( MediaId $mediaId ) : array |
|
111 | + public function sendLike(MediaId $mediaId) : array |
|
112 | 112 | { |
113 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
113 | + if (false == ($mediaId instanceof MediaId)) |
|
114 | 114 | { |
115 | - throw new LikeException ( "Current param isn't instance of MediaId." ); |
|
115 | + throw new LikeException("Current param isn't instance of MediaId."); |
|
116 | 116 | } |
117 | 117 | |
118 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/likes", $mediaId ); |
|
118 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/likes", $mediaId); |
|
119 | 119 | |
120 | - $this->builder->addResource ( "access_token", $this->accessToken ); |
|
120 | + $this->builder->addResource("access_token", $this->accessToken); |
|
121 | 121 | |
122 | - $request = $this->requestFactory->createRequest ( "POST", $uri, [ |
|
123 | - "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary () . '"' |
|
124 | - ], ( string ) $this->builder->build () ); |
|
122 | + $request = $this->requestFactory->createRequest("POST", $uri, [ |
|
123 | + "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary() . '"' |
|
124 | + ], ( string ) $this->builder->build()); |
|
125 | 125 | |
126 | - $response = $this->httpClient->sendRequest ( $request ); |
|
126 | + $response = $this->httpClient->sendRequest($request); |
|
127 | 127 | |
128 | - if ( $response->getStatusCode () === 400 ) |
|
128 | + if ($response->getStatusCode() === 400) |
|
129 | 129 | { |
130 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
130 | + $body = json_decode(( string ) $response->getBody()); |
|
131 | 131 | |
132 | - throw new LikeException ( $body->meta->error_message ); |
|
132 | + throw new LikeException($body->meta->error_message); |
|
133 | 133 | } |
134 | 134 | |
135 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
135 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -141,30 +141,30 @@ discard block |
||
141 | 141 | * @param object MediaId $mediaId |
142 | 142 | * @return array |
143 | 143 | */ |
144 | - public function deleteLike ( MediaId $mediaId ) : array |
|
144 | + public function deleteLike(MediaId $mediaId) : array |
|
145 | 145 | { |
146 | - if ( false == ( $mediaId instanceof MediaId ) ) |
|
146 | + if (false == ($mediaId instanceof MediaId)) |
|
147 | 147 | { |
148 | - throw new LikeException ( "Current param isn't instance of MediaId." ); |
|
148 | + throw new LikeException("Current param isn't instance of MediaId."); |
|
149 | 149 | } |
150 | 150 | |
151 | - $uri = sprintf ( "https://api.instagram.com/v1/media/%s/likes", $mediaId ); |
|
151 | + $uri = sprintf("https://api.instagram.com/v1/media/%s/likes", $mediaId); |
|
152 | 152 | |
153 | - $this->builder->addResource ( "access_token", $this->accessToken ); |
|
153 | + $this->builder->addResource("access_token", $this->accessToken); |
|
154 | 154 | |
155 | - $request = $this->requestFactory->createRequest ( "DELETE", $uri, [ |
|
156 | - "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary () . '"' |
|
157 | - ], ( string ) $this->builder->build () ); |
|
155 | + $request = $this->requestFactory->createRequest("DELETE", $uri, [ |
|
156 | + "Content-Type" => 'multipart/form-data; boundary="' . $this->builder->getBoundary() . '"' |
|
157 | + ], ( string ) $this->builder->build()); |
|
158 | 158 | |
159 | - $response = $this->httpClient->sendRequest ( $request ); |
|
159 | + $response = $this->httpClient->sendRequest($request); |
|
160 | 160 | |
161 | - if ( $response->getStatusCode () === 400 ) |
|
161 | + if ($response->getStatusCode() === 400) |
|
162 | 162 | { |
163 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
163 | + $body = json_decode(( string ) $response->getBody()); |
|
164 | 164 | |
165 | - throw new LikeException ( $body->meta->error_message ); |
|
165 | + throw new LikeException($body->meta->error_message); |
|
166 | 166 | } |
167 | 167 | |
168 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
168 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Endpoints; |
6 | 6 | |
@@ -39,25 +39,25 @@ discard block |
||
39 | 39 | * @param \Http\Client\HttpClient|null $httpClient |
40 | 40 | * @param \Http\Message\RequestFactory|null $requestFactory |
41 | 41 | */ |
42 | - public function __construct ( HttpClient $httpClient = null, RequestFactory $requestFactory = null ) |
|
42 | + public function __construct(HttpClient $httpClient = null, RequestFactory $requestFactory = null) |
|
43 | 43 | { |
44 | - $this->httpClient = $httpClient ?: HttpClientDiscovery::find (); |
|
44 | + $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); |
|
45 | 45 | |
46 | - $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find (); |
|
46 | + $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param Access Token Setter |
51 | 51 | */ |
52 | - public function setToken ( $token ) |
|
52 | + public function setToken($token) |
|
53 | 53 | { |
54 | - $this->accessToken = new AccessToken ( $token ); |
|
54 | + $this->accessToken = new AccessToken($token); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @return Access Token Getter |
59 | 59 | */ |
60 | - public function getToken () : AccessToken |
|
60 | + public function getToken() : AccessToken |
|
61 | 61 | { |
62 | 62 | return $this->accessToken; |
63 | 63 | } |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param string $tagName |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - public function listTag ( TagName $tagName ) : array |
|
71 | + public function listTag(TagName $tagName) : array |
|
72 | 72 | { |
73 | - if ( false == ( $tagName instanceof TagName ) ) |
|
73 | + if (false == ($tagName instanceof TagName)) |
|
74 | 74 | { |
75 | - throw new TagException ( "Current param isn't instance of TagName." ); |
|
75 | + throw new TagException("Current param isn't instance of TagName."); |
|
76 | 76 | } |
77 | 77 | |
78 | - $uri = sprintf ( "https://api.instagram.com/v1/tags/%s?access_token=%s", $tagName, $this->accessToken ); |
|
78 | + $uri = sprintf("https://api.instagram.com/v1/tags/%s?access_token=%s", $tagName, $this->accessToken); |
|
79 | 79 | |
80 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
80 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
81 | 81 | |
82 | - $response = $this->httpClient->sendRequest ( $request ); |
|
82 | + $response = $this->httpClient->sendRequest($request); |
|
83 | 83 | |
84 | - if ( $response->getStatusCode () === 400 ) |
|
84 | + if ($response->getStatusCode() === 400) |
|
85 | 85 | { |
86 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
86 | + $body = json_decode(( string ) $response->getBody()); |
|
87 | 87 | |
88 | - throw new TagException ( $body->meta->error_message ); |
|
88 | + throw new TagException($body->meta->error_message); |
|
89 | 89 | } |
90 | 90 | |
91 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
91 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | * @param string $tagName |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - public function infoTag ( TagName $tagName ) : array |
|
100 | + public function infoTag(TagName $tagName) : array |
|
101 | 101 | { |
102 | - if ( false == ( $tagName instanceof TagName ) ) |
|
102 | + if (false == ($tagName instanceof TagName)) |
|
103 | 103 | { |
104 | - throw new TagException ( "Current param isn't instance of TagName." ); |
|
104 | + throw new TagException("Current param isn't instance of TagName."); |
|
105 | 105 | } |
106 | 106 | |
107 | - $uri = sprintf ( "https://api.instagram.com/v1/tags/%s/media/recent?access_token=%s", $tagName, $this->accessToken ); |
|
107 | + $uri = sprintf("https://api.instagram.com/v1/tags/%s/media/recent?access_token=%s", $tagName, $this->accessToken); |
|
108 | 108 | |
109 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
109 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
110 | 110 | |
111 | - $response = $this->httpClient->sendRequest ( $request ); |
|
111 | + $response = $this->httpClient->sendRequest($request); |
|
112 | 112 | |
113 | - if ( $response->getStatusCode () === 400 ) |
|
113 | + if ($response->getStatusCode() === 400) |
|
114 | 114 | { |
115 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
115 | + $body = json_decode(( string ) $response->getBody()); |
|
116 | 116 | |
117 | - throw new TagException ( $body->meta->error_message ); |
|
117 | + throw new TagException($body->meta->error_message); |
|
118 | 118 | } |
119 | 119 | |
120 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
120 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -126,26 +126,26 @@ discard block |
||
126 | 126 | * @param string $tagName |
127 | 127 | * @return array |
128 | 128 | */ |
129 | - public function searchTag ( TagName $tagName ) : array |
|
129 | + public function searchTag(TagName $tagName) : array |
|
130 | 130 | { |
131 | - if ( false == ( $tagName instanceof TagName ) ) |
|
131 | + if (false == ($tagName instanceof TagName)) |
|
132 | 132 | { |
133 | - throw new TagException ( "Current param isn't instance of TagName." ); |
|
133 | + throw new TagException("Current param isn't instance of TagName."); |
|
134 | 134 | } |
135 | 135 | |
136 | - $uri = sprintf ( "https://api.instagram.com/v1/tags/search?q=%s&access_token=%s", $tagName, $this->accessToken ); |
|
136 | + $uri = sprintf("https://api.instagram.com/v1/tags/search?q=%s&access_token=%s", $tagName, $this->accessToken); |
|
137 | 137 | |
138 | - $request = $this->requestFactory->createRequest ( "GET", $uri ); |
|
138 | + $request = $this->requestFactory->createRequest("GET", $uri); |
|
139 | 139 | |
140 | - $response = $this->httpClient->sendRequest ( $request ); |
|
140 | + $response = $this->httpClient->sendRequest($request); |
|
141 | 141 | |
142 | - if ( $response->getStatusCode () === 400 ) |
|
142 | + if ($response->getStatusCode() === 400) |
|
143 | 143 | { |
144 | - $body = json_decode ( ( string ) $response->getBody () ); |
|
144 | + $body = json_decode(( string ) $response->getBody()); |
|
145 | 145 | |
146 | - throw new TagException ( $body->meta->error_message ); |
|
146 | + throw new TagException($body->meta->error_message); |
|
147 | 147 | } |
148 | 148 | |
149 | - return json_decode ( ( string ) $response->getBody ()->getContents (), true ); |
|
149 | + return json_decode(( string ) $response->getBody()->getContents(), true); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | \ No newline at end of file |
@@ -11,5 +11,5 @@ |
||
11 | 11 | */ |
12 | 12 | class CommentException extends RuntimeException |
13 | 13 | { |
14 | - // |
|
14 | + // |
|
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Exceptions; |
6 | 6 |
@@ -11,5 +11,5 @@ |
||
11 | 11 | */ |
12 | 12 | class LikeException extends RuntimeException |
13 | 13 | { |
14 | - // |
|
14 | + // |
|
15 | 15 | } |
16 | 16 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare ( strict_types = 1 ); |
|
3 | +declare (strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace Ch0c01dxyz\InstaToken\Exceptions; |
6 | 6 |