This repository has been archived by the owner on Nov 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest2.php
59 lines (49 loc) · 1.6 KB
/
test2.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
<meta charset="utf-8" />
<?php
$snn = $_GET["q"];
//$api = 'http://mp3.zing.vn/suggest/search?term=".$snn."';
//đọc nội dung API
$api = 'http://mp3.zing.vn/ajax/lyric-v2/lyrics?id=ZW6UF98O';
$get = get_by_curl($api);
//bóc tách
//echo $get;
$json = json_decode($get, true);
$name = $json['result'];
$artist = $json['name']['artist'];
$hinhanh = $json['name'];
//echo "<meta http-equiv='refresh' content='0;".$audio."' download>";
echo $name."<br/>";
echo $artist."<br/>";
echo $hinhanh."<br/>";
?>
<?php
function get_by_curl($url){
//echo "curl:url<pre>".$url."</pre><BR>";
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 15, // timeout on connect
CURLOPT_TIMEOUT => 15, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_SSL_VERIFYPEER => false,
);
$ch = curl_init($url);
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch,CURLINFO_EFFECTIVE_URL );
curl_close( $ch );
//$header['errno'] = $err;
// $header['errmsg'] = $errmsg;
//change errmsg here to errno
if ($errmsg)
{
echo "";
}
return $content;
}
?>