Реализовал доступ к ВК по опознаку (token)
This commit is contained in:
parent
a70327d64c
commit
a55301131c
@ -37,21 +37,22 @@ class TelegramPromoter(Promoter):
|
|||||||
|
|
||||||
class VkontaktePromoter(Promoter):
|
class VkontaktePromoter(Promoter):
|
||||||
def promote(self):
|
def promote(self):
|
||||||
vk_login = promoter_secrets['VK_LOGIN']
|
|
||||||
vk_password = promoter_secrets['VK_PASSWORD']
|
|
||||||
vk_owner_id = promoter_secrets['VK_OWNER_ID']
|
vk_owner_id = promoter_secrets['VK_OWNER_ID']
|
||||||
|
vk_token = promoter_secrets['VK_TOKEN']
|
||||||
import vk_api
|
from_group = 1
|
||||||
session = vk_api.VkApi(login=vk_login,
|
|
||||||
password=vk_password)
|
|
||||||
session.auth()
|
|
||||||
api = session.get_api()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
api.wall.post(owner_id=vk_owner_id,
|
requests.post('https://api.vk.com/method/wall.post',
|
||||||
message=self.article.body,
|
params={
|
||||||
attachments=self.article.link)
|
'access_token': vk_token,
|
||||||
except vk_api.VkApiError as exc:
|
'owner_id': vk_owner_id,
|
||||||
|
'from_group': from_group,
|
||||||
|
'message': self.article.body,
|
||||||
|
'attachment': self.article.link,
|
||||||
|
'signed': 0,
|
||||||
|
'v': '5.131'
|
||||||
|
})
|
||||||
|
except Exception as exc:
|
||||||
raise PromoteError(exc)
|
raise PromoteError(exc)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user