我正在尝试使用 curl 从受密码保护的 JSON 提要中获取数据,但结果会在提要的开头添加“数组(”,并在末尾添加“)”,使其无效。
我正在使用这段代码:
<?php
$url = 'https://slx.arlcap.com/sdata/rcs/tablet/products/Y6UJ9A00000Z/filings';
$username = 'xxx';
$password = 'xxx';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($ch, CURLOPT_REFERER, $url);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$data = json_decode($result, true);
print_r($data);
?>
结果在这里: http ://www.motion.tc//DataTables-1.9.0/examples/ajax/feed.php
有没有一种方法可以在不添加“Array()”元素的情况下返回数据?
谢谢!安德鲁