Skip to content

Commit

Permalink
Add comment about sending multiple media as media_data
Browse files Browse the repository at this point in the history
  • Loading branch information
mynetx committed May 26, 2014
1 parent 25e00ad commit af039bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions codebird-cors-proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ function http_get_request_body()
$body = http_get_request_body();

// check for media parameter
// TODO support multiple media[] params after Twitter allows them
// for uploading multiple medias, use media_data, see
// https://dev.twitter.com/docs/api/multiple-media-extended-entities

if (isset($_POST['media']) && is_array($_POST['media'])) {
$body = $_POST;
Expand Down Expand Up @@ -171,7 +172,13 @@ function http_get_request_body()
header('HTTP/1.1 412 Precondition failed');
die('This proxy only supports requests to API version 1.1.');
}
$url = 'https://api.twitter.com' . substr($url, $version_pos);
// use media endpoint if necessary
$is_media_upload = strpos($url, 'media/upload.json') !== false;
if ($is_media_upload) {
$url = 'https://upload.twitter.com' . substr($url, $version_pos);
} else {
$url = 'https://api.twitter.com' . substr($url, $version_pos);
}

// send request to Twitter API
$ch = curl_init($url);
Expand Down

0 comments on commit af039bf

Please sign in to comment.