php function vk method data token url https api vk com method method i

 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
<?php
function vk($method, $data, $token=""){
$url="https://api.vk.com/method/".$method;
if($curl = curl_init()){
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
$data['access_token']=$token;
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$out = curl_exec($curl);
return json_decode($out, true);
curl_close($curl);
}
}
$page = file_get_contents("http://www.lastfm.ru/user/");
preg_match_all('@<tr class="first"(.*?)subjectCell highlight">(.*?)>(.*?)<(.*?)<(.*?)>(.*?)<@sui', $page, $a);
$audio = vk("audio.search", array(
"q" => htmlspecialchars_decode($a[3][0])." ".htmlspecialchars_decode($a[6][0])
));
vk("audio.setBroadcast", array(
"audio" => $audio["response"][1]["owner_id"]."_".$audio["response"][1]["aid"]
));