SoundCloud API 提供空白页



当我尝试 SoundCloud API (http://api.soundcloud.com/users/mezomefans.json?consumer_key=xxxxxxxxxx) 时,它会提供数据

{"id":153870451,"kind":"user","permalink":"mezomefans","username":"mezomefans","last_modified":"2017/05/15 18:45:01 +0000","uri":"https://api.soundcloud.com/users/153870451","permalink_url":"http://soundcloud.com/mezomefans","avatar_url":"https://i1.sndcdn.com/avatars-000280458917-j6ilmo-large.jpg","country":null,"first_name":"","last_name":"","full_name":"","description":null,"city":"","discogs_name":null,"myspace_name":null,"website":null,"website_title":null,"track_count":1,"playlist_count":0,"online":false,"plan":"Free","public_favorites_count":28,"followers_count":9,"followings_count":12,"subscriptions":[],"reposts_count":0}

但是当我尝试PHP时,它给了我空白页并且没有提供任何数据

我的代码是:

<?php
$url = file_get_contents("http://api.soundcloud.com/users/mezomefans.json?consumer_key=xxxxxxxxxx");
preg_match("'"followers_count":(.*?),'si", $url, $matches);
$followers = preg_replace("/[^0-9]/", "", $matches[1]);
echo $followers;
 ?>

知道如何通过php检索数据吗?

这是

旧的users端点,您应该使用/users/{USER_ID}端点。

首先,获取用户的用户 ID (153870451)。

然后,构造您的请求:

HTTP GET: http://api.soundcloud.com/users/153870451?client_id={CLIENT_ID}

响应:

{
  "id": 153870451,
  "kind": "user",
  "permalink": "mezomefans",
  "username": "mezomefans",
  "last_modified": "2017/05/15 18:45:01 +0000",
  "uri": "https://api.soundcloud.com/users/153870451",
  "permalink_url": "http://soundcloud.com/mezomefans",
  "avatar_url": "https://i1.sndcdn.com/avatars-000280458917-j6ilmo-large.jpg",
  "country": null,
  "first_name": "",
  "last_name": "",
  "full_name": "",
  "description": null,
  "city": "",
  "discogs_name": null,
  "myspace_name": null,
  "website": null,
  "website_title": null,
  "track_count": 1,
  "playlist_count": 0,
  "online": false,
  "plan": "Free",
  "public_favorites_count": 28,
  "followers_count": 9,
  "followings_count": 12,
  "subscriptions": [],
  "reposts_count": 0
}

最新更新