curl -X GET 'https://ad.oceanengine.com/open_api/oauth2/advertiser/get/' -H 'Content-Type: application/json' -d' { "app_id": 0, "secret": "", "access_token": "xxx" }转化为php代码
时间: 2023-03-19 16:24:41 浏览: 310
curl-to-php:在浏览器中将curl命令转换为PHP代码
$data = array("app_id" => 0, "secret" => "", "access_token" => "xxx");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://ad.oceanengine.com/open_api/oauth2/advertiser/get/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
阅读全文