Пример #1
0
 def form_valid(self, form):
     if form.is_valid():
         post_to = get_test_group_id()
         post_to = "-" + post_to
         method = "wall.post"
         request_params = {"owner_id": post_to, "message": form.cleaned_data["text"]}
         r = make_request_from_user(method, get_my_main_user_id(), request_params)
         print r.text
         return super(SimpleVkWallPost, self).form_valid(form)
     else:
         return self.form_invalid(form)
Пример #2
0
def send_random_pictures_from_vk_album(owner_id, album_id, pix_count, message, need_clear=False):
    album, _ = models.VkAlbum.objects.get_or_create(vk_owner_id=owner_id, vk_object_id=album_id)
    album.syncronize(need_clear=need_clear)
    photos = album.get_rand_unused_photos(pix_count)
    attach_text = ''
    for photo in photos:
        attach_text += photo.get_textual() + ','
        photo.mark_used()
    attach_text = attach_text[:len(attach_text)-1]
    post_to = get_current_group_id()
    post_to = '-' + post_to
    method = 'wall.post'
    request_params = {
        'owner_id': post_to,
        'message': message,
        'attachments': attach_text,
        'from_group': 1
    }
    r = make_request_from_user(method, get_my_main_user_id(), request_params)
    return r.text