Skip to content

Instantly share code, notes, and snippets.

@masazdream
Last active June 30, 2021 11:43
Show Gist options
  • Save masazdream/6026844 to your computer and use it in GitHub Desktop.
Save masazdream/6026844 to your computer and use it in GitHub Desktop.
curl php で binary data を no key name で送る。
$ch2 = curl_init($url);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE); // -k
curl_setopt($ch2, CURLOPT_POST, TRUE); // POST
curl_setopt($ch2, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt($ch2, CURLOPT_HTTPHEADER, ['Content-Type: text/xml;charset=utf-8', 'User-Agent: curl']); // Http Header
// 返り値を文字列として受け取る場合はONに
//curl_setopt($ch2, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($ch2, CURLOPT_TRANSFERTEXT, TRUE);
//curl_setopt($ch2, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($ch2, CURLINFO_HEADER_OUT, TRUE);
$xml_flie = 動画のフルパス;
$postdata = file_get_contents($xml_flie);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $postdata);
$response = curl_exec($ch2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment