每次我需要使用php curl时我都很挣扎。文档非常糟糕,我最终做了反复试验。如何将此控制台命令转换为php curl代码:
curl -H "X-Futuresimple-Token: token" "https://appointments.futuresimple.com/api/v1/appointments.json"
答案 0 :(得分:0)
尝试这样的事情:
$curl = curl_init();
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'X-Futuresimple-Token: token' ) );
curl_setopt( $curl, CURLOPT_URL, 'https://appointments.futuresimple.com/api/v1/appointments.json' );
$result = curl_exec( $curl );
if ( $result === false ) {
die( 'Error fetching data: ' . curl_error( $curl ) );
}
curl_close( $curl );