T
T
tajew2015-10-28 14:52:41
JavaScript
tajew, 2015-10-28 14:52:41

How to initialize api classmates?

Using the following code:

<script type="text/javascript" src="//api.ok.ru/js/fapi5.js" defer="defer"></script>

var rParams = FAPI.Util.getRequestParameters();
  FAPI.init(rParams["api_server"], rParams["apiconnection"],
        /*
        * Первый параметр:
        * функция, которая будет вызвана после успешной инициализации.
        */
        function() {
            alert("Инициализация прошла успешно");
            // здесь можно вызывать методы API
        },
        /*
        * Второй параметр:
        * функция, которая будет вызвана, если инициализация не удалась.
        */
        function(error) {
            alert("Ошибка инициализации");
        }
  );

I get an error
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://test.ru') does not match the recipient window's origin ('http://test.ru').

In the application settings is https://test.ru/okapp
test.ru - I just hid my domain. Everything is fine with the real domain, the host is not local, the ssl certificate is installed.
Another game on this domain, but on the http:// protocol it initializes fine, but now http can not be used.
VK games on this domain using the https protocol work fine.
What could be the problem? Thank you!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vjacheslav Kanivetc, 2015-10-29
@tajew

Look at the example https://github.com/apiok/ok-js-sdk/blob/master/sam... (not FAPI5 is used here, but a slightly newer version of the SDK, but the principle is the same)
And there is not enough data for the request itself to understand the cause of the error. If it doesn’t work out, then it would be right to make an example on github (gh-pages branch) with which the problem repeats so that you can see it

S
Scribblex, 2015-10-28
@Scribblex

It seems to me that the problem is with the protocol: http and https, not sure

A
Arman Misakyan, 2015-10-28
@arman455

friends tell me please how to register in api classmates?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question