Add support for view-only mode.
[patchfork.git] / player / openstrands.php
1 <?php
2 /* 
3     Pitchfork Music Player Daemon Client
4     Copyright (C) 2007  Roger Bystrøm
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; version 2 of the License.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20         function strands_send_request($url) {
21                 $STRANDS_URL = "https://www.mystrands.com/services";
22
23                 $url = $STRANDS_URL . $url . "&subscriberId=5a05bc1dd3d608e96c8d336daf3544c5";
24                 $xml = @file_get_contents($url);
25                 $xml = @simplexml_load_string($xml);
26                 return $xml;
27         }
28
29         /*
30          * artists must be an array
31          */
32         function strands_get_recommendations($artists) {
33                 $url = "num=15&";
34                 foreach($artists as $a) 
35                         $url .= "&name=" . urlencode($a);
36                 $url = "/recommend/artists?" . $url;
37
38                 $res = strands_send_request($url);
39
40                 if(!$res)
41                         return false;
42
43                 $ret = array();
44                 if(!$res->SimpleArtist) return $ret;
45
46                 foreach($res->SimpleArtist as $sa) {
47                         if($sa->ArtistName)
48                                 $ret[] = (string)$sa->ArtistName;
49
50                 }
51                 return $ret;
52         }
53
54 ?>
This page took 0.021065 seconds and 4 git commands to generate.