Answer the question
In order to leave comments, you need to log in
How to place large posts in Odnoklassniki via API?
There is a working script for posting, it works with posts that are small in terms of text.
mydict='{ "media": [ { "type": "text", "text": "'+text_post+'" }, { "type": "photo", "list": ['+pic_LIST+']}], "publishAtMs": "'+date+'", "onBehalfOfGroup": "true"}'
p1='application_key='+key+'attachment='+mydict+'format=jsongid='+id_gr+'method=mediatopic.posttype='+self.type_post+session
h=hashlib.md5(p1.encode("UTF-8"))
sig=h.hexdigest()
att = urllib.parse.quote(mydict, safe='utf-8')
#Загрузка поста
url='https://api.ok.ru/fb.do?application_key='+key+'&attachment='+str(att)+'&format=json&gid='+id_gr+'&method=mediatopic.post&type='+self.type_post+'&sig='+sig+'&access_token='+access_token
r = requests.post(url)
print(r.text)
mydict='{ "media": [ { "type": "text", "text": "'+text+'" }, { "type": "photo", "list": [{ "id":"'+pic_tokken+'"}]}], "publishAtMs": "'+date+'", "onBehalfOfGroup": "true"}'
att = urllib.parse.quote(mydict, safe='utf-8')
p1={'application_key': app_key,
'attachment':mydict,
'format':'json',
'gid':id_gr,
'method':'mediatopic.post',
'type':post_type2
}
h=hashlib.md5(str(p1).encode('utf-8')+'{token}{secret}'.format(token=access_token,secret=privat_key).encode('utf-8'))
sig=h.hexdigest()
print(sig)
r = requests.post('https://api.ok.ru/fb.do', params={'application_key':app_key, 'attachment':str(att), 'format':'json', 'gid':id_gr, 'method':'mediatopic.post', 'type':post_type2}, data={'access_token': access_token, 'sig':sig})
$params = array(
"application_key" => $ok_public_key,
"method" => "mediatopic.post",
"gid" => $ok_group_id,
"type" => "GROUP_THEME",
"attachment" => $attachment,
"format" => "json",
);
// Подпишем
$sig = md5( arInStr($params) . md5("{$ok_access_token}{$ok_private_key}") );
$params['access_token'] = $ok_access_token;
$params['sig'] = $sig;
$step3 = json_decode( getUrl("https://api.ok.ru/fb.do", "POST", $params, 30, false, false ), true);
Answer the question
In order to leave comments, you need to log in
You have generated a url for a get request.
You need to form the request like this:
where the query parameters will be in the data dictionary.
Or change requests.post(url) to requests.get(url)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question