コマンドラインカールをphp curlに翻訳する
curlをサポートする場合、コマンドからこれらのコマンドを翻訳するのは難しい場合がありますPHPスクリプトへの行。この記事では、特定のCurlコマンドをPHPに変換するための詳細なソリューションを提供します。 -data-binary "@test.png" \ -h "content-type:image/png" \ "http://hostname/@api/deki/pages/ = testpage/files/=test.png" \ -0
php curl翻訳:
curl -b cookie.txt -X PUT \ --data-binary "@test.png" \ -H "Content-Type: image/png" \ "http://hostname/@api/deki/pages/=TestPage/files/=test.png" \ -0
を定義することができます。 URLおよびファイル名の動的部分の変数:
$ pageurl = "http:// hostname/@api/deki/pages/= testpage/files/="; $ filename = "test.png";
construct construct construct construct construct constry:
$pageurl = "http://hostname/@api/deki/pages/=TestPage/files/="; $filename = "test.png";
curl requestを初期化:
$theurl = $pageurl . $filename;
set curlオプション元のコマンドを一致させるには:
$ch = curl_init($theurl);
これらの手順に従うことにより、コマンドラインCurlコマンドをPHPに正常に翻訳し、スクリプトからAPIと対話します。 Curlオプションの詳細については、PHPマニュアル:http://www.php.net/manual/en/function.curl-setopt.phpを参照してください。
免責事項: 提供されるすべてのリソースの一部はインターネットからのものです。お客様の著作権またはその他の権利および利益の侵害がある場合は、詳細な理由を説明し、著作権または権利および利益の証拠を提出して、電子メール [email protected] に送信してください。 できるだけ早く対応させていただきます。
Copyright© 2022 湘ICP备2022001581号-3