【发布时间】:2016-02-03 23:08:18
【问题描述】:
所以我有以下代码:
<?PHP
$remote_url = 'https://www.haloapi.com/stats/h5/players/PLAYER/matches';
// Create a stream
$opts = array(
'http'=>array(
'method'=>"GET",
'header' => "Ocp-Apim-Subscription-Key: MY SUBSCRIPTION KEY")
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents($remote_url, false, $context);
print(json_decode($file));
?>
它给了我以下错误:
可捕获的致命错误:第 17 行的 C:\xampp\htdocs\HaloAPItest\index.php 中的类 stdClass 的对象无法转换为字符串
我该怎么办?
【问题讨论】:
-
您在寻找
print_r(),而不是print()。
标签: php