@@ -77,8 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | if(!empty($parameters)) { |
79 | 79 | $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); |
80 | - } |
|
81 | - else { |
|
80 | + } else { |
|
82 | 81 | $path = $endpoint; |
83 | 82 | } |
84 | 83 | |
@@ -180,8 +179,9 @@ discard block |
||
180 | 179 | CURLOPT_POSTFIELDS => $parameters |
181 | 180 | ) ); |
182 | 181 | |
183 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
184 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
182 | + if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) { |
|
183 | + $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
184 | + } |
|
185 | 185 | |
186 | 186 | break; |
187 | 187 | case 'DELETE': |
@@ -89,8 +89,8 @@ |
||
89 | 89 | * Make a post request to the given endpoint |
90 | 90 | * |
91 | 91 | * @access public |
92 | - * @param string $path |
|
93 | 92 | * @param array $parameters |
93 | + * @param string $endpoint |
|
94 | 94 | * @return Response |
95 | 95 | */ |
96 | 96 | public function post( $endpoint, array $parameters = array() ) |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @param CurlBuilder $curlbuilder |
50 | 50 | */ |
51 | - public function __construct( CurlBuilder $curlbuilder ) |
|
51 | + public function __construct(CurlBuilder $curlbuilder) |
|
52 | 52 | { |
53 | 53 | $this->curlbuilder = $curlbuilder; |
54 | 54 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @param string $token |
61 | 61 | * @return void |
62 | 62 | */ |
63 | - public function setAccessToken( $token ) |
|
63 | + public function setAccessToken($token) |
|
64 | 64 | { |
65 | 65 | $this->access_token = $token; |
66 | 66 | } |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | * @param array $parameters |
74 | 74 | * @return Response |
75 | 75 | */ |
76 | - public function get( $endpoint, array $parameters = array() ) |
|
76 | + public function get($endpoint, array $parameters = array()) |
|
77 | 77 | { |
78 | - if(!empty($parameters)) { |
|
78 | + if (!empty($parameters)) { |
|
79 | 79 | $path = sprintf("%s/?%s", $endpoint, http_build_query($parameters)); |
80 | 80 | } |
81 | 81 | else { |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | * @param array $parameters |
94 | 94 | * @return Response |
95 | 95 | */ |
96 | - public function post( $endpoint, array $parameters = array() ) |
|
96 | + public function post($endpoint, array $parameters = array()) |
|
97 | 97 | { |
98 | - return $this->execute("POST", sprintf("%s%s", $this->host, $endpoint), $parameters ); |
|
98 | + return $this->execute("POST", sprintf("%s%s", $this->host, $endpoint), $parameters); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param array $parameters |
107 | 107 | * @return Response |
108 | 108 | */ |
109 | - public function delete( $endpoint, array $parameters = array() ) |
|
109 | + public function delete($endpoint, array $parameters = array()) |
|
110 | 110 | { |
111 | - return $this->execute("DELETE", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters ); |
|
111 | + return $this->execute("DELETE", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * @param array $parameters |
120 | 120 | * @return Response |
121 | 121 | */ |
122 | - public function update( $endpoint, array $parameters = array() ) |
|
122 | + public function update($endpoint, array $parameters = array()) |
|
123 | 123 | { |
124 | - return $this->execute("PATCH", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters ); |
|
124 | + return $this->execute("PATCH", sprintf("%s%s", $this->host, $endpoint) . "/", $parameters); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -144,10 +144,10 @@ discard block |
||
144 | 144 | * @param array $headers |
145 | 145 | * @return Response |
146 | 146 | */ |
147 | - public function execute( $method, $apiCall, array $parameters = array(), $headers = array() ) |
|
147 | + public function execute($method, $apiCall, array $parameters = array(), $headers = array()) |
|
148 | 148 | { |
149 | 149 | // Check if the access token needs to be added |
150 | - if($this->access_token != null){ |
|
150 | + if ($this->access_token != null) { |
|
151 | 151 | $headers = array_merge($headers, array( |
152 | 152 | "Authorization: Bearer " . $this->access_token, |
153 | 153 | "Content-ype: multipart/form-data", |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $ch = $this->curlbuilder->create(); |
159 | 159 | |
160 | 160 | // Set default options |
161 | - $ch->setOptions( array( |
|
161 | + $ch->setOptions(array( |
|
162 | 162 | CURLOPT_URL => $apiCall, |
163 | 163 | CURLOPT_HTTPHEADER => $headers, |
164 | 164 | CURLOPT_CONNECTTIMEOUT => 20, |
@@ -168,28 +168,28 @@ discard block |
||
168 | 168 | CURLOPT_SSL_VERIFYHOST => false, |
169 | 169 | CURLOPT_HEADER => false, |
170 | 170 | CURLINFO_HEADER_OUT => true |
171 | - ) ); |
|
171 | + )); |
|
172 | 172 | |
173 | 173 | switch ($method) { |
174 | 174 | case 'POST': |
175 | - $ch->setOptions( array( |
|
175 | + $ch->setOptions(array( |
|
176 | 176 | CURLOPT_CUSTOMREQUEST => 'POST', |
177 | 177 | CURLOPT_POST => count($parameters), |
178 | 178 | CURLOPT_POSTFIELDS => $parameters |
179 | - ) ); |
|
179 | + )); |
|
180 | 180 | |
181 | - if(!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
182 | - $ch->setOption( CURLOPT_SAFE_UPLOAD, false ); |
|
181 | + if (!class_exists("\CURLFile") && defined('CURLOPT_SAFE_UPLOAD')) |
|
182 | + $ch->setOption(CURLOPT_SAFE_UPLOAD, false); |
|
183 | 183 | |
184 | 184 | break; |
185 | 185 | case 'DELETE': |
186 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "DELETE" ); |
|
186 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
187 | 187 | break; |
188 | 188 | case 'PATCH': |
189 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "PATCH" ); |
|
189 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "PATCH"); |
|
190 | 190 | break; |
191 | 191 | default: |
192 | - $ch->setOption( CURLOPT_CUSTOMREQUEST, "GET" ); |
|
192 | + $ch->setOption(CURLOPT_CUSTOMREQUEST, "GET"); |
|
193 | 193 | break; |
194 | 194 | } |
195 | 195 | |
@@ -198,16 +198,16 @@ discard block |
||
198 | 198 | $response_data = $ch->execute(); |
199 | 199 | |
200 | 200 | // Check if we have a valid response |
201 | - if ( !$response_data || $ch->hasErrors() ) { |
|
202 | - throw new PinterestException( 'Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber() ); |
|
201 | + if (!$response_data || $ch->hasErrors()) { |
|
202 | + throw new PinterestException('Error: execute() - cURL error: ' . $ch->getErrors(), $ch->getErrorNumber()); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Initiate the response |
206 | 206 | $response = new Response($response_data, $ch); |
207 | 207 | |
208 | 208 | // Check the response code |
209 | - if ( $response->getResponseCode() >= 400 ) { |
|
210 | - throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode() ); |
|
209 | + if ($response->getResponseCode() >= 400) { |
|
210 | + throw new PinterestException('Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode()); |
|
211 | 211 | } |
212 | 212 | $this->headers = $ch->getHeaders(); |
213 | 213 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 Dirk Groenen |
|
4 | - * |
|
5 | - * (c) Dirk Groenen <[email protected]> |
|
6 | - * |
|
7 | - * For the full copyright and license information, please view the LICENSE |
|
8 | - * file that was distributed with this source code. |
|
9 | - */ |
|
3 | + * Copyright 2015 Dirk Groenen |
|
4 | + * |
|
5 | + * (c) Dirk Groenen <[email protected]> |
|
6 | + * |
|
7 | + * For the full copyright and license information, please view the LICENSE |
|
8 | + * file that was distributed with this source code. |
|
9 | + */ |
|
10 | 10 | |
11 | 11 | namespace DirkGroenen\Pinterest\Endpoints; |
12 | 12 |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | * @throws Exceptions/PinterestExceptions |
25 | 25 | * @return Collection |
26 | 26 | */ |
27 | - public function users( array $data = [] ) |
|
27 | + public function users(array $data = []) |
|
28 | 28 | { |
29 | - $response = $this->request->get( "me/following/users", $data ); |
|
30 | - return new Collection( $this->master, $response, "User" ); |
|
29 | + $response = $this->request->get("me/following/users", $data); |
|
30 | + return new Collection($this->master, $response, "User"); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | * @throws Exceptions/PinterestExceptions |
39 | 39 | * @return Collection |
40 | 40 | */ |
41 | - public function boards( array $data = [] ) |
|
41 | + public function boards(array $data = []) |
|
42 | 42 | { |
43 | - $response = $this->request->get( "me/following/boards", $data ); |
|
44 | - return new Collection( $this->master, $response, "Board" ); |
|
43 | + $response = $this->request->get("me/following/boards", $data); |
|
44 | + return new Collection($this->master, $response, "Board"); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | * @throws Exceptions/PinterestExceptions |
53 | 53 | * @return Collection |
54 | 54 | */ |
55 | - public function interests( array $data = [] ) |
|
55 | + public function interests(array $data = []) |
|
56 | 56 | { |
57 | - $response = $this->request->get( "me/following/interests", $data ); |
|
58 | - return new Collection( $this->master, $response, "Interest" ); |
|
57 | + $response = $this->request->get("me/following/interests", $data); |
|
58 | + return new Collection($this->master, $response, "Interest"); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @throws Exceptions/PinterestExceptions |
67 | 67 | * @return boolean |
68 | 68 | */ |
69 | - public function followUser( $user ) |
|
69 | + public function followUser($user) |
|
70 | 70 | { |
71 | - $this->request->post( "me/following/users", array( |
|
71 | + $this->request->post("me/following/users", array( |
|
72 | 72 | "user" => $user |
73 | - ) ); |
|
73 | + )); |
|
74 | 74 | return true; |
75 | 75 | } |
76 | 76 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @throws Exceptions/PinterestExceptions |
83 | 83 | * @return boolean |
84 | 84 | */ |
85 | - public function unfollowUser( $user ) |
|
85 | + public function unfollowUser($user) |
|
86 | 86 | { |
87 | - $this->request->delete( sprintf("me/following/users/%s", $user) ); |
|
87 | + $this->request->delete(sprintf("me/following/users/%s", $user)); |
|
88 | 88 | return true; |
89 | 89 | } |
90 | 90 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @throws Exceptions/PinterestExceptions |
97 | 97 | * @return boolean |
98 | 98 | */ |
99 | - public function followBoard( $board ) |
|
99 | + public function followBoard($board) |
|
100 | 100 | { |
101 | - $this->request->post( "me/following/boards", array( |
|
101 | + $this->request->post("me/following/boards", array( |
|
102 | 102 | "board" => $board |
103 | - ) ); |
|
103 | + )); |
|
104 | 104 | return true; |
105 | 105 | } |
106 | 106 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | * @throws Exceptions/PinterestExceptions |
113 | 113 | * @return boolean |
114 | 114 | */ |
115 | - public function unfollowBoard( $board_id ) |
|
115 | + public function unfollowBoard($board_id) |
|
116 | 116 | { |
117 | - $this->request->delete( sprintf("me/following/boards/%s", $board_id) ); |
|
117 | + $this->request->delete(sprintf("me/following/boards/%s", $board_id)); |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @throws Exceptions/PinterestExceptions |
127 | 127 | * @return boolean |
128 | 128 | */ |
129 | - public function followInterest( $interest ) |
|
129 | + public function followInterest($interest) |
|
130 | 130 | { |
131 | - $this->request->post( "me/following/interests", array( |
|
131 | + $this->request->post("me/following/interests", array( |
|
132 | 132 | "interest" => $interest |
133 | - ) ); |
|
133 | + )); |
|
134 | 134 | return true; |
135 | 135 | } |
136 | 136 | |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @throws Exceptions/PinterestExceptions |
143 | 143 | * @return boolean |
144 | 144 | */ |
145 | - public function unfollowInterest( $interest_id ) |
|
145 | + public function unfollowInterest($interest_id) |
|
146 | 146 | { |
147 | - $this->request->delete( sprintf("me/following/interests/%s", $interest_id) ); |
|
147 | + $this->request->delete(sprintf("me/following/interests/%s", $interest_id)); |
|
148 | 148 | return true; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | \ No newline at end of file |