如何将此curl命令转换为php curl代码?(How can I transform this curl command into php curl code?)
每次我需要使用php curl时都会挣扎。 文档很糟糕,我最终做了试验和错误。 如何将此控制台命令转换为php curl代码:
curl -H "X-Futuresimple-Token: token" "https://appointments.futuresimple.com/api/v1/appointments.json"I struggle everytime I need to use php curl. The documentation is pretty bad and I endup doing trial and error. How can I convert this console command into php curl code:
curl -H "X-Futuresimple-Token: token" "https://appointments.futuresimple.com/api/v1/appointments.json"最满意答案
尝试这样的事情:
$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 );Try something like this:
$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 );更多推荐
发布评论