📜  将 php 转换为 curl - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:43.103000             🧑  作者: Mango

代码示例2
$localFile = 'C:\SampleWithout-URL.json';

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://globalshipmeds.com/values/Upload',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => array('' => new CurlFile($localFile)),
    CURLOPT_HTTPHEADER => array(
        'Authorization: Bearer evzPukXUMTiEtjk4s3gijNmG8LhGH7suo0Rk9vyoGXt6X15pRseSGxa829B0JcQKE0yp8CtY37pc37cEw_rF8GcgIa6iv_WKsvBBoAvAAShWkq_sJK_v99qjirUqP0qpZXjPTJNfuerxooGQhy8PS11ZBmtelOgByWAMJD_pABuGebmk1ASWepfFBAcPu9zjpo8jqD9XsitUmdSNtkbho2-Lr1kOubTA_lF9_9jdyJpL444KcLDUHi3OjEjcPXc_s-XVEK49KYjzcuK6YCUyeu5f1r0rW9GPV_3C4SfFqNt4nrdjRvhx_UhZvYsoGBFE'),
));

$response = curl_exec($curl);

curl_close($curl);
print_r($response);