M
M
Mikhail Kobzarev2014-05-22 00:55:19
JavaScript
Mikhail Kobzarev, 2014-05-22 00:55:19

Getting a list of friends from Odnoklassniki

From the API docs ( apiok.ru/wiki/display/api/FAPI.init+ru ) you can see that you first need to initialize the API itself. But here a plug immediately arises: rParams is empty. What am I doing wrong?

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript" src="//api.odnoklassniki.ru/js/fapi5.js"></script>
    <script>
        var rParams = FAPI.Util.getRequestParameters(); console.log(rParams);
        FAPI.init(rParams["api_server"], rParams["apiconnection"],
                function() { console.log('ok')},
                function( error ) {  console.log(error); }
        );
    </script>
</head>
<body>

</body>
</html>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Valery Ozhiganov, 2015-02-07
@vozhiganov

fapi5.js is intended for games that will be opened on Odnoklassniki itself ( like these ), so if you are just making an external application / site, then this library is not suitable for it.

E
Eugene_Sh, 2014-05-22
@Eugene_Sh

Try replacing the line:
On the:

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

M
Mikhail Kobzarev, 2014-05-23
@mihdan

No options?

9
96467840, 2014-07-04
@96467840

in general, the point is that GET parameters must contain all application parameters apiok.ru/wiki/pages/viewpage.action?pageId=42476523 (and all internal link transitions in the frame must contain them)
here is the code of the FAPI.Util function. getRequestParameters()

getRequestParameters: function() {
            var l = new Array();
            var g = window.location.search;
            console.log(window.location.href);
            if (g) {
                g = g.substr(1);
                var k = g.split("&");
                for (var h = 0; h < k.length; h++) {
                    var e = k[h].split("=");
                    var f = e[0];
                    var m = e[1];
                    m = decodeURIComponent(m.replace(/\+/g, " "));
                    l[f] = m;
                }
            }
            return l;
        }

the documentation highlights:
the API must be initialized before the first use using the FAPI.init method.
All parameters passed to your application at startup are recommended to be copied unchanged to all navigation links inside the iframe of your application. At least all navigation links must contain the following parameters:
•api_server
•apiconnection
•web_server
•application_key
•session_key
•session_secret_key
After each transition, the FAPI.init method must be reinitialized.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question