Closed jhyoo2 closed 2 years ago
@jhyoo2 can you share more details on the error? What is the exception message?
it shows like this.
My guess is that this is a problem with the sdk. I'm using cocos-creator now and I'm importing the file uploaded in the example(https://github.com/heroiclabs/nakama-cocos2d-x-javascript). If you look at the "nakama-js.umd.js" file on this page, you will find the following.
NakamaApi.prototype.importFacebookFriends = function (body, reset, options) {
if (options === void 0) { options = {}; }
if (body === null || body === undefined) {
throw new Error("'body' is a required parameter but is null or undefined.");
}
var urlPath = "/v2/friend/facebook";
var queryParams = {
reset: reset,
};
var _body = null;
_body = JSON.stringify(body || {});
return this.doFetch(urlPath, "POST", queryParams, _body, options);
};
I followed up a bit and found When you call a function"await client.importFacebookFriends(token, reset);", then the function above is called. However, the "token" is being passed as a "body". So, the value of _body at the end comes out as "true", and this value is passed to the subsequent function.
Sorry @jhyoo2 I'm not following -- I don't see anywhere that we pass token
instead of body
: you can see here where we do the passing from the client to the inner api client https://github.com/heroiclabs/nakama-cocos2d-x-javascript/blob/master/NakamaSDK/nakama-js.umd.js#L2377
Yep, you just picked the right location. If you look at the location you sent, it appears that you are receiving a session object that has a token variable as a parameter. However, if you actually print the log, the session is just output as a string type variable with a token value.
@jhyoo2 okay, can you pass your body object instead of a token?
I try few things and In the end, the transaction was successful, but the function to load the friend list still does not work.
The modified sdk code is as follows.
//modified;
Client.prototype.importFacebookFriends = function (token, reset) {
return (
this.apiClient
//modified;
.importFacebookFriends({ token: token, vars: null }, reset, {})
.then(function (response) {
console.log(response);
return response !== undefined;
})
);
};
If I do this, the transaction is completed without a 401 or 400 error like the last time. There is a friend of mine who I checked through the FB API now, but that person is not being input to the NAKAMA server.
There seems to be a problem with the friend list sync process. During authentication, I found the following phenomenon:
Works Client.authenticateFacebook(accessToken, true, "username", false)
Makes Error Client.authenticateFacebook(accessToken, true, "username", true)
If you set the Sync Option to true like this, an error occurs. I know this is also a friend list sync feature, right? There seems to be some problem between the api and the current sdk.
The code I just posted is working. I just checked Your friend list is syncing. :)
Hi guys.
I have a problem while load facebook friend with nakama server.
(1) code → here is the code I using : I am using typescript. await client.importFacebookFriends(token, reset);
(2) result → when I using that code or code like below
Could it be a problem with cocos-creator SDK?
We are using Facebook api version 13.0, is there a version difference?
and I don’t know how to solve it.
Anyone can help me?