Skip to content

Commit d5bc3a1

Browse files
committed
Provide PHP5.3 compatibility in video sample code
1 parent 6419558 commit d5bc3a1

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ $fp = fopen($file, 'r');
252252

253253
// INIT the upload
254254

255-
$reply = $cb->media_upload([
255+
$reply = $cb->media_upload(array(
256256
'command' => 'INIT',
257257
'media_type' => 'video/mp4',
258258
'total_bytes' => $size_bytes
259-
]);
259+
));
260260

261261
$media_id = $reply->media_id_string;
262262

@@ -267,12 +267,12 @@ $segment_id = 0;
267267
while (! feof($fp)) {
268268
$chunk = fread($fp, 1048576); // 1MB per chunk for this sample
269269

270-
$reply = $cb->media_upload([
270+
$reply = $cb->media_upload(array(
271271
'command' => 'APPEND',
272272
'media_id' => $media_id,
273273
'segment_index' => $segment_id,
274274
'media' => $chunk
275-
]);
275+
));
276276

277277
$segment_id++;
278278
}
@@ -281,10 +281,10 @@ fclose($fp);
281281

282282
// FINALIZE the upload
283283

284-
$reply = $cb->media_upload([
284+
$reply = $cb->media_upload(array(
285285
'command' => 'FINALIZE',
286286
'media_id' => $media_id
287-
]);
287+
));
288288

289289
var_dump($reply);
290290

@@ -293,11 +293,10 @@ if ($reply->httpstatus < 200 || $reply->httpstatus > 299) {
293293
}
294294

295295
// Now use the media_id in a tweet
296-
$reply = $cb->statuses_update([
296+
$reply = $cb->statuses_update(array(
297297
'status' => 'Twitter now accepts video uploads.',
298298
'media_ids' => $media_id
299-
]);
300-
299+
));
301300
```
302301

303302
:warning: The Twitter API reproducibly rejected some MP4 videos even though they are valid. It’s currently undocumented which video codecs are supported and which are not.

0 commit comments

Comments
 (0)