卷曲 PHP 仅显示空白页
Curl in PHP just showing a blank page
我尝试使用curl 获取内容,但任何地址总是显示空白页。 reqbin.com.
一切正常
请帮我找到解决办法...
<?php
$url = "https://api.airtable.com/v0/appTUTmrwscX1mD4y/Orders?maxRecords=3&view=Grid%20view";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Authorization: Bearer HIDDEN_KEY",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
?>
我不能完全弄清楚这个问题,因为你已经将 CURLOPT_RETURNTRANSFER
设置为 true,但也许你可以尝试使用 file_get_contents()
,因为这是获得的传统方法API数据:
$options = array(
'http'=> array(
'method' => "GET",
'header' => "Authorization: Bearer HIDDEN_KEY"
)
);
$context = stream_context_create($options);
$data = file_get_contents('https://api.airtable.com/v0/appTUTmrwscX1mD4y/Orders?maxRecords=3&view=Grid%20view', false, $context);
问题出在 php-curl 上,它没有安装到我的服务器上。安装后问题解决。谢谢回复。
我尝试使用curl 获取内容,但任何地址总是显示空白页。 reqbin.com.
一切正常请帮我找到解决办法...
<?php
$url = "https://api.airtable.com/v0/appTUTmrwscX1mD4y/Orders?maxRecords=3&view=Grid%20view";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Authorization: Bearer HIDDEN_KEY",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
?>
我不能完全弄清楚这个问题,因为你已经将 CURLOPT_RETURNTRANSFER
设置为 true,但也许你可以尝试使用 file_get_contents()
,因为这是获得的传统方法API数据:
$options = array(
'http'=> array(
'method' => "GET",
'header' => "Authorization: Bearer HIDDEN_KEY"
)
);
$context = stream_context_create($options);
$data = file_get_contents('https://api.airtable.com/v0/appTUTmrwscX1mD4y/Orders?maxRecords=3&view=Grid%20view', false, $context);
问题出在 php-curl 上,它没有安装到我的服务器上。安装后问题解决。谢谢回复。