пример можно посмотреть тут -
http://vk.com/app2134400_23898673 основан на нескольких уроках, которые мне просто лень указывать, блок представляет собой вывод случайно выбранного друга и возможностью запостить на его стену сообщение, блок обновляется без перезагрузки страницы через заданное вами время
Код скрипта:
<script type="text/javascript">
VK.init(function(){
getFriend();
});
$(document).ready(function(){
getFriend();
});
function getFriend(){
$('#inviteFriend').fadeOut();
VK.api('friends.get',{fields: 'uid,first_name,last_name,photo_rec,sex'},function(data){
friend_n = Math.floor(Math.random()*$(data.response).size());
friend_id = data.response[friend_n].uid;
friend_name = data.response[friend_n].first_name;
//alert(friend_id);
invHtml = '<div class="infoBlock clearFix" >';
invHtml+= '<div style="height: 60px; overflow: hidden; float: left; margin-right: 6px;">';
invHtml+= '<IMG src="'+data.response[friend_n].photo_rec+'" height="50" alt="" style="margin-bottom: -2px;">';
invHtml+= '</div>';
invHtml+= '<div style="float: left; width: 106px;">';
invHtml+= '<a href="#">'+data.response[friend_n].first_name+'</a></br>';
invHtml+= 'еще не ';
invHtml+= '<span>'+(data.response[friend_n].sex == 1 ? 'была':'был')+'</span> в Кинозале?</br></br>';
invHtml+= '<div style="float: right; margin-top: 4px;">';
invHtml+= '<input value=Пригласить type=button onclick=sendwallwindow() >';
invHtml+= '</div>';
invHtml+= '</div>';
invHtml+= '</div>';
$('#inviteFriend').html(invHtml).fadeIn();
});
}
setInterval('getFriend()', 10000);
function sendwallwindow(user_id){
VK.api("wall.post", { owner_id:friend_id, message:"Заходи, тут очень много фильмов! Есть ЧАТ!", attachment:'photo23898673_268709136,photo23898673_268709137,photo23898673_268709138,photo23898673_268709139,photo23898673_268709140,photo23898673_268709141,photo23898673_268709142,photo23898673_268709143,photo23898673_268709144,http://vkontakte.ru/app2134400_23898673' }, function(data) {
alert(data.response);
if (data.response) alert("Сообщение успешно отправлено.");
});
}
</script>
Код блока (его вставить в нужном месте):
<div id="Friend"style="background: #0851ab; margin: 10px; width:200px; height:110px;">
<div class="inviteFriend">
<div id="inviteFriend"style="background: #0851ab; padding: 4px;width:180px; height:100px;"></div>
</div>
</div>
Вид поста выглядит так (в моем случае) -
