C:\xampp2_not used\htdocs\kptv\ro\func\cover.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php 
    
    error_reporting
(E_ALL);
    
ini_set('display_errors',1); 
    
    
/**
     * Download cover image by artist/track
    */
    
    
class Cover {
        
        private 
$artist;
        private 
$track;
        private 
$searchType;
        
        private 
$API_URL "http://api.spotify.com/v1/search?q={search_term}&type={search_type}";
        private 
$searchTypes = array('artist''track');
    
        private 
$rawResult NULL;
        private 
$rawObject NULL;
    
        public function 
__construct($artist ""$track ""$searchType "artist"){
            if(!empty(
$artist) && !empty($track)) {
                
$this->artist $artist;
                
$this->track $track;
                
$this->searchType $searchType;
            }
        }
        
        public function 
doSearch() {
            
$requestURL $this->API_URL;
            
$requestURL str_replace("{search_type}"$this->searchType$requestURL);
            
            
$searchTerm urlencode((($this->searchType == $this->searchTypes[0]) ? $this->artist $this->track));
            
$requestURL str_replace("{search_term}"$searchTerm$requestURL);            
            
            try {
                
$this->rawResult file_get_contents($requestURL);
            } catch(
Exception $e) {
                
var_dump($e);
            }
            
$this->rawObject json_decode($this->rawResulttrue);
        }
    
        private function 
get_data($url) {
            
$ch curl_init();
            
curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
            
curl_setopt($chCURLOPT_HEADERfalse);
            
curl_setopt($chCURLOPT_FOLLOWLOCATIONtrue);
            
curl_setopt($chCURLOPT_URL$url);
            
curl_setopt($chCURLOPT_REFERER$url);
            
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);
            
$result curl_exec($ch);
            
curl_close($ch);
            return 
$result;
        }
    
        public function 
getRawResult(){
            return 
$this->rawResult;
        }
        
        public function 
returnRawResultObject(){
            return 
$this->rawObject;
        }
    }
        
    
?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586