Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Use the wall.get VK API method ( https://vk.com/dev/wall.get).
In PHP like this:
var_dump(wallGet($owner_id, $count)); //должен вывести массив записей сообщества $owner_id, в количестве $count
function wallGet($owner_id, $count) {
$result = api('wall.get', array(
'owner_id' => -(int)$owner_id,
'count' =>(int)$count,
));
if ($result !== false) {
return $result['items'];
}
else {
return false;
}
}
function api($method, $params) {
$params['access_token'] = $access_token;
$params['v'] = $api_version;
$url = 'https://api.vk.com/method/' . $method;
if (!function_exists('curl_init')) {
die('ERROR: CURL library not found!');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 (.NET CLR 3.5.30729)",
"Accept-Language: en-us,en;q=0.5}"
));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$json = curl_exec($ch);
$error = curl_error($ch);
if ($error) {
error_log($error);
return false;
}
curl_close($ch);
$response = json_decode($json, true);
if (!$response || !isset($response['response'])) {
error_log($json);
return false;
}
return $response['response'];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question