A
A
Artem2018-05-15 17:28:26
Classmates
Artem, 2018-05-15 17:28:26

WidgetMediatopicPost for what reason "error_code":"104","error_msg":"Bad signature "?

Hello, the WidgetMediatopicPost function throws an error 104, can anyone tell me what this is related to? Can anyone come across?
Here is the code that throws the error

OKSDK.init(config, function () {
               console.log("получилось");
                 

                OKSDK.REST.call(
                    'users.getCurrentUser',
                     null, 
                     function (status, data, error) {
                        if (status == 'ok') {
                                alert("yes");
                                console.log(data);
                                $('#id_ok').val(data.uid);
                                $('#name_ok').val(data.name);
                                $('#surname_ok').val(data.last_name);

                                var tree =  {"media": [
                                    {
                                        "type": "text",
                                        "text": "hello"
                                    }
                                ]};

                            // Объект tree в JSON строку
                            var str_tree = JSON.stringify(tree);

                            // Кодируем JSON строку для подстановки в URI, как параметра
                            var coding_str_json = encodeURIComponent(str_tree);
                            var secret_key = getParameterByName('session_secret_key');
                            var st_return = 'https://my.site.ru/';
                            //var access_token = getParameterByName('access_token');
                            var access_token = '-s-aIic8Iwxhjg9grzvFp93d-V0El89AJwVDjf5bMw-9******************FlA5cr.x7LAfhM.UCh78BJwd';
                            //var signature_md5 = "st.attachment=" + str_tree + "st.return=" + st_return + secret_key;
                            var signature_md5 = "st.attachment=" + tree + secret_key;
                            var signature = md5( "st.attachment=" + tree + secret_key);

                            document.location.href="https://connect.ok.ru/dk?" +
                            "st.cmd=WidgetMediatopicPost&" +
                            "st.app=1265742592&" +
                            "st.attachment=" + coding_str_json + "&" +
                            "st.signature=" + signature + "&" +
                           // "st.return=" + st_return + "&" +
                            "st.access_token=" + access_token;



                        } else {
                            alert('Unable to retrieve current user ' + OKSDK.Util.toString(error));
                        }
                    });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vjacheslav Kanivetc, 2018-06-07
@Vjaka

You _already_ use ok-js-sdk
So why not use OKSDK.Widgets.post(...) which will calculate the signature itself?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question