I'm请求,像这样的API(Domain是NSFW)之前完全地加载:PHP:瓦亭的JSON来对其进行解码
$external_videoid = "ph57fbb82bd33ab";
$string = file_get_contents("http://www.pornhub.com/webmasters/video_by_id?id=".$external_videoid."&thumbsize=big");
$json = json_decode($string, true);
$title = $json["video"]["title"];
echo $string;
但我不能获取任何数据。 $ title是空的。回声给我:
<html><head>[...]<bodyonload="go()">Loading...</body>[...]</html>
这可能表明我想检索的JSON是以某种方式加载,我猜。对我来说似乎很清楚。似乎file_get_contents必须等待该站点加载。我能做什么?
APPEND:有时请求有效。有时它不会。
我认为“载入中...”这个称号:)。 print_r($ json)的结果是什么; ? – mayersdesign
print_r($ json)为NULL。加载意味着什么?标题是空的。 “