-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlasfm2vk.php
31 lines (26 loc) · 1.02 KB
/
lasfm2vk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$access_token = '<TOKEN>';
function scrobbler() {
$request_url = 'http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=<USER>&api_key=<API_KEY>';
$xml = simplexml_load_file ($request_url);
$title = $xml->recenttracks->track->name;
$artist = $xml->recenttracks->track->artist;
$album = $xml->recenttracks->track->album;
$nowplaying = $xml->recenttracks->track->attributes()->nowplaying;
if (!is_null($nowplaying) && $nowplaying == 'true') {
return '🔊 ' . $artist . ' / ' . $album . ' / ' . $title;
}
return '🔇';
}
$status = scrobbler();
$url = curl('https://api.vk.com/method/status.set?text='.urlencode($status).'&access_token='.$access_token.'&v='5.81');
function curl( $url ){
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$response = curl_exec( $ch );
curl_close( $ch );
return $response;
}
?>