【发布时间】:2020-09-04 04:58:44
【问题描述】:
我正在使用一个 api,它给了我一个非常奇怪的 json 格式.. 我正在发布它的数据,我正在通过它..
info = { "title" : "Asian Dad: B Again!? (you die)", "image" : "http://i.ytimg.com/vi/IN7o2Iy89WQ/default.jpg", "length" : "2", "status" : "serving", "progress_speed" : "", "progress" : "", "ads" : "", "pf" : "", "h" : "f53762dab34022e9d851ab71e0bf166f" };
我正在尝试在 php 中打印此数据,但我无法做到这一点..我的网页上没有显示任何内容,.... 我的代码是..
我第一次尝试,
<?php
$url="http://www.website-name.com/a/itemInfo/?video_id=IN7o2Iy89WQ&ac=www";
$info=file_get_contents($url);
$info=json_decode($info,true);
echo $info;
?>
我的第二次尝试是,
<?php
$url="http://www.website-name.com/a/itemInfo/?video_id=IN7o2Iy89WQ&ac=www";
$info=file_get_contents($url);
$info=json_decode($info,true);
$info->h;
?>
我最后一次尝试是,
<?php
$url="http://www.website-name.com/a/itemInfo/?video_id=IN7o2Iy89WQ&ac=www";
$info=file_get_contents($url);
$info=json_decode($info,true);
$info['h'];
?>
什么都没有发生..
请有人帮助我
API 网址已转换...
【问题讨论】:
-
$url="http://www.website-name.com/itemInfo/?video_id=IN7o2Iy89WQ&ac=www";这是在发送 JSON 吗?你确定吗? -
你能在第二行和第三行之后
var_dump($info);向我们展示输出吗? -
@SasankaPanguluri 请立即检查..
-
@TheWolf ...如果我使用 var_dump($info);,我的网页显示为 NULL