用于cURL PHP的cURL命令

时间:2016-07-17 12:43:44

标签: php curl

我试图将这个cURL命令放在PHP中,但它似乎还没有工作。

我想将SRT文件发布到https://atelier.u-sub.net/srt2vtt/index.php,因为该网站会将SRT转换为VVT文件。我想将网站的输出(VVT文件)保存到我服务器上的文件中。当我在Linux服务器上运行cURL命令时,它会输出VVT文件(这样就可以了。)

命令:

curl --form "subrip_file=@Stranger.Things.S01E08.720p.WEBRip.x264-SKGTV.srt" https://atelier.u-sub.net/srt2vtt/index.php

我的PHP代码:

$request = curl_init('https://atelier.u-sub.net/srt2vtt/index.php');

// send a file
curl_setopt($request, CURLOPT_POST, true);
curl_setopt(
$request,
CURLOPT_POSTFIELDS,
array(
  'subrip_file' => '@' . realpath('Stranger.Things.S01E08.720p.WEBRip.x264-SKGTV.srt')
));

// output the response
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($request);

// close the session
curl_close($request); 

0 个答案:

没有答案