A
A
AnteFil2022-04-02 18:34:17
PHP
AnteFil, 2022-04-02 18:34:17

OK.RU Does not work in a group. What's wrong?

I did not find a direct API for posting to my group. Found through the widget!
https://apiok.ru/ext/publish
Wrote a small code in php. But I ran into a problem
62486cb377391608402425.jpeg
. What kind of error is this and what is connected with, I do not understand! How do you get the post to be sent?

<?php
function Post_Url($url, $params=array(), $timeout=15) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode(http_build_query($params)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
 

$ok_access_token = "0000000";//Наш вечный токен
$ok_private_key = "0000000";//Секретный ключ приложения
$ok_public_key = "0000000";//Публичный ключ приложения
$ok_id_priloj = "0000000";
$ok_id_grup = "0000000";
$params = array(
    "st.app"=>$ok_id_priloj,
    "st.groupId"=>$ok_id_grup,
    "st.cmd"=>"WidgetMediatopicPost",

);
$arr[] = array('type' => 'text', 'text' => 'текст тестовый');
$data_v_json= json_encode(array('media' => $arr), JSON_UNESCAPED_UNICODE);

$sig = md5("st.attachment=".$params["st.attachment"].$ok_private_key);
$params["st.attachment"]=$data_v_json;
$params["st.access_token"]=$ok_private_key;
$params["st.signature"]=$sig;

$result = Post_Url("https://connect.ok.ru/dk", $params);

echo '<pre>';
print_r($result);	
?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question