如何将第三方API集成到wordpress主题。是否有用于cURL调用的预构建wordpress函数?
以下是带有参数的代码:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => {{API_URL}},
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_HTTPHEADER => array(
"host: {{API_HOST}}"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);