【问题标题】:Parse JSON in PHP with Link使用链接在 PHP 中解析 JSON
【发布时间】:2017-02-26 14:17:50
【问题描述】:

this 是我的 JSON 文件。我将在 PHP 中解析“Titel”和“Album”:

当前歌曲:标题(专辑)

我怎样才能用 PHP 做到这一点?谁能发给我完整的 PHP 文件?

【问题讨论】:

  • 你能添加任何代码吗?
  • Stackoverflow 不是代码编写服务。
  • 谁能给我发一份完整的 PHP 文件? 是的,在你给我们提供服务的全额付款之后。

标签: php json parsing radio


【解决方案1】:

嗯,这应该很简单:

<?php

function get_content($URL){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_URL, $URL);
      $data = curl_exec($ch);
      curl_close($ch);
      return $data;
}

//$json = file_get_contents("http://api.laut.fm/station/radiojfm/current_song");

$json = get_content("http://api.laut.fm/station/radiojfm/current_song");
$data = json_decode($json, true);

echo $data["title"]." ".$data["album"];

?>

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-12
  • 2011-02-09
  • 2020-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多