curl-xpost(php)
我有下面的Curl命令。如何在PHP中执行此操作curl-xpost(php),php,Php,我有下面的Curl命令。如何在PHP中执行此操作 curl -X POST "https://api.mystream.to/v1/remote-upload" -H "Authorization: ACCESS_TOKEN" -d "url=<URL>&path=<PATH?>" curl-X POST”https://api.mystream.to/v1/remote-upload" -H“授权:访问令牌” -d“url=&path=” 下面是PHP
curl -X POST "https://api.mystream.to/v1/remote-upload"
-H "Authorization: ACCESS_TOKEN"
-d "url=<URL>&path=<PATH?>"
curl-X POST”https://api.mystream.to/v1/remote-upload"
-H“授权:访问令牌”
-d“url=&path=”
下面是PHP代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mystream.to/v1/remote-upload');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "url=<URL>&path=<PATH?>");
$headers = array();
$headers[] = 'Authorization: ACCESS_TOKEN';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result=curl\u exec($ch)代码>
检查以下网站,它将为您转换该代码。
$headers[] = 'Authorization: ACCESS_TOKEN';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);