V
V
vcow2016-03-30 13:42:44
JavaScript
vcow, 2016-03-30 13:42:44

Why is the FAPI.UI function not called from IFrame?

When trying to call FAPI.UI.showInvite() from an IFrame, the invite does not open, an error occurs in API_callback with the code -1 and the description: "UI methods are available only for apps running on OK portal". I'm using FAPI5. The FAPI and FAPI.Client methods are called normally. There is not a word in the documentation about restrictions and ways to bypass them. How do I call invites and post media?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vcow, 2016-03-30
@vcow

The problem turned out to be in the way initialization was called - init was called by name:

...
var methodName = "init";
var params = [api_server, apiconnection];
...
params.push(callbackSuccess);
params.push(callbackFail);
...
FAPI[methodName].apply(this, params);
...

At the same time, callbackSuccess() was called as expected, FAPI.Client.call() worked properly, but all FAPI.UI methods returned an error.
After changing the call to
...
FAPI.init(params[0], params[1], callbackSuccess, callbackFail);
...

Everything worked as it should. Why the call by name does not work correctly, it was not possible to find out.

V
Vjacheslav Kanivetc, 2016-03-30
@Vjaka

Judging by the message, the application still does not start in the iframe of classmates on ok.ru/game/.... Perhaps you've added another iframe where you haven't passed enough parameters to initialize the widgets OK?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question