protected static function fetch_tarball_via_oauth($key, $secret, $uri)
{
try {
$oauth = new OAuth($key, $secret);
$oauth->fetch($uri);
WP_CLI::debug($oauth->getLastResponseHeaders());
$headers = http_parse_headers($oauth->getLastResponseHeaders());
$mime_type = self::parse_content_type_header($headers['Content-Type']);
$content_disposition = self::parse_content_disposition_header($headers['Content-Disposition']);
$filename = empty($content_disposition['filename']) ? $filename = tmpfile() : sys_get_temp_dir() . DIRECTORY_SEPARATOR . $content_disposition['filename'];
file_put_contents($filename, $oauth->getLastResponse());
return $filename;
} catch (OAuthException $e) {
WP_CLI::error_multi_line($e->getMessage(), true);
}
WP_CLI::error('Unknown error', true);
}