@@ -163,36 +163,18 @@ $params = array(
163
163
);
164
164
$reply = $cb->users_show($params);
165
165
```
166
-
167
- ### Uploading files to Twitter
168
-
169
- The array syntax is obligatory:
170
-
171
- ``` php
172
- $params = array(
173
- 'status' => 'Look at this crazy cat! #lolcats',
174
- 'media[]' => '/home/jublonet/lolcats.jpg'
175
- );
176
- $reply = $cb->statuses_updateWithMedia($params);
177
- ```
178
-
179
- Remote files received from ` http ` and ` https ` servers are supported, too:
180
- ``` php
181
- $reply = $cb->statuses_updateWithMedia(array(
182
- 'status' => 'This is the Guggenheim museum in Bilbao, Spain, as seen by @Bing.',
183
- 'media[]' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
184
- ));
185
- ```
186
-
187
166
This is the [ resulting tweet] ( https://twitter.com/LarryMcTweet/status/482239971399835648 )
188
167
sent with the code above.
189
168
190
- #### Multiple images
191
- can be uploaded in a 2-step process. ** First** you send each image to Twitter, like this:
169
+ ### Uploading media to Twitter
170
+
171
+ Tweet media can be uploaded in a 2-step process.
172
+ ** First** you send each image to Twitter, like this:
173
+
192
174
``` php
193
- // these files to upload
175
+ // these files to upload. You can also just upload 1 image!
194
176
$media_files = array(
195
- 'bird1.jpg', 'bird2.jpg', 'bird3.jpg' // http/https URLs allowed here, too!
177
+ 'bird1.jpg', 'bird2.jpg', 'bird3.jpg'
196
178
);
197
179
// will hold the uploaded IDs
198
180
$media_ids = array();
@@ -206,6 +188,7 @@ foreach ($media_files as $file) {
206
188
$media_ids[] = $reply->media_id_string;
207
189
}
208
190
```
191
+
209
192
** Second,** you attach the collected media ids for all images to your call
210
193
to ``` statuses/update ``` , like this:
211
194
@@ -221,10 +204,20 @@ $reply = $cb->statuses_update(array(
221
204
print_r($reply);
222
205
);
223
206
```
207
+
224
208
Here is a [ sample tweet] ( https://twitter.com/LarryMcTweet/status/475276535386365952 )
225
209
sent with the code above.
226
210
227
- More [ documentation for tweeting with multiple media] ( https://dev.twitter.com/docs/api/multiple-media-extended-entities ) is available on the Twitter Developer site.
211
+ More [ documentation for tweeting with media] ( https://dev.twitter.com/rest/public/uploading-media-multiple-photos ) is available on the Twitter Developer site.
212
+
213
+ #### Remote files
214
+
215
+ Remote files received from ` http ` and ` https ` servers are supported, too:
216
+ ``` php
217
+ $reply = $cb->media_upload(array(
218
+ 'media' => 'http://www.bing.com/az/hprichbg/rb/BilbaoGuggenheim_EN-US11232447099_1366x768.jpg'
219
+ ));
220
+ ```
228
221
229
222
### Requests with app-only auth
230
223
@@ -279,10 +272,10 @@ The library returns the response HTTP status code, so you can detect rate limits
279
272
I suggest you to check if the ``` $reply->httpstatus ``` property is ``` 400 ```
280
273
and check with the Twitter API to find out if you are currently being
281
274
rate-limited.
282
- See the [ Rate Limiting FAQ] ( https://dev.twitter.com/docs/ rate-limiting-faq )
275
+ See the [ Rate Limiting FAQ] ( https://dev.twitter.com/rest/public/ rate-limiting )
283
276
for more information.
284
277
285
- Unless your return format is JOSN , you will receive rate-limiting details
278
+ Unless your return format is JSON , you will receive rate-limiting details
286
279
in the returned data’s ``` $reply->rate ``` property,
287
280
if the Twitter API responds with rate-limiting HTTP headers.
288
281
0 commit comments