您知道如何將我想轉換為 guzzle http 的 curl 代碼轉換嗎?
curl -X POST "https://api.cloudflare.com/client/v4/accounts/023e105f4ecef8ad9ca31a8372d0c353/stream" \
-H "X-Auth-Email: [email protected]" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
--form 'file=@/Users/kyle/Desktop/skiing.mp4'
我的貪吃代碼
$token = config('services.cloudflare.token');
$accountId = config('services.cloudflare.acountId');
$client = new Client();
$response =$client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/' . $accountId . '/stream', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
"Content-Type" => "application/json",
],
'multipart' => [
[
'name' => 'upload',
'filename' => 'fl',
'contents' => fopen($file,'r '),
'name' => 'new-video.' . $file->getClientOriginalExtension(),
],
]
]);
echo $response->getBody();
uj5u.com熱心網友回復:
Laravel 和 Cloudflare,我最不喜歡的兩個東西。
直接使用 PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudflare.com/client/v4/accounts/023e105f4ecef8ad9ca31a8372d0c353/stream');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Auth-Email' => '[email protected]',
'X-Auth-Key' => 'c2547eb745079dac9320b638f5e225cf483cc5cfdda41',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'file' => new CURLFile('/Users/kyle/Desktop/skiing.mp4'),
]);
$response = curl_exec($ch);
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/524553.html
標籤:php卷曲狂饮
上一篇:curl命令到python-requests方法的轉換
下一篇:卷曲命令沒有接受正確的變數
