Jamendo 对机器人广播音乐的更多呼吁
More call for bot Radio music in Jamendo
我正在制作一个机器人电报,以通过他们的 API 收听 Jamendo 电台。
我写了这个:
$url_radio = 'https://api.jamendo.com/v3.0/radios/stream/?client_id='.CLIENT_ID_J.'&format=jsonpretty&name='.$id;
$result = file_get_contents($url_radio);
$update = json_decode($result, true);
$res = $update['results'];
$sendto =API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($res[0]['dispname']);
file_get_contents($sendto);
$sendto =API_URL."sendPhoto?chat_id=".$chatID."&photo=".urlencode($res[0]['playingnow']['track_image']);
file_get_contents($sendto);
$name = $res[0]['playingnow']['track_name'].' - '.$res[0]['playingnow']['artist_name'];
$url_track = 'https://api.jamendo.com/v3.0/albums/tracks/?client_id='.CLIENT_ID_J.'&track_id='.$res[0]['playingnow']['track_id'];
$result = file_get_contents($url_track);
$update = json_decode($result, true);
$res = $update['results'][0];
$sendto =API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($name.chr(10).$res["tracks"][0]['audio']);
file_get_contents($sendto);
它工作得很好,但我会通过以下方式避免太多调用:"file_get_contents($sendto);"。
是否有其他方法可以避免这 3 个调用?
如果我清楚地理解了你的问题,你就可以避免一个问题。
SendPhoto API method 有标题参数。您可以使用此字段显示 $res[0]['dispname']
我正在制作一个机器人电报,以通过他们的 API 收听 Jamendo 电台。 我写了这个:
$url_radio = 'https://api.jamendo.com/v3.0/radios/stream/?client_id='.CLIENT_ID_J.'&format=jsonpretty&name='.$id;
$result = file_get_contents($url_radio);
$update = json_decode($result, true);
$res = $update['results'];
$sendto =API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($res[0]['dispname']);
file_get_contents($sendto);
$sendto =API_URL."sendPhoto?chat_id=".$chatID."&photo=".urlencode($res[0]['playingnow']['track_image']);
file_get_contents($sendto);
$name = $res[0]['playingnow']['track_name'].' - '.$res[0]['playingnow']['artist_name'];
$url_track = 'https://api.jamendo.com/v3.0/albums/tracks/?client_id='.CLIENT_ID_J.'&track_id='.$res[0]['playingnow']['track_id'];
$result = file_get_contents($url_track);
$update = json_decode($result, true);
$res = $update['results'][0];
$sendto =API_URL."sendmessage?chat_id=".$chatID."&text=".urlencode($name.chr(10).$res["tracks"][0]['audio']);
file_get_contents($sendto);
它工作得很好,但我会通过以下方式避免太多调用:"file_get_contents($sendto);"。
是否有其他方法可以避免这 3 个调用?
如果我清楚地理解了你的问题,你就可以避免一个问题。
SendPhoto API method 有标题参数。您可以使用此字段显示 $res[0]['dispname']