Relation chain
Unity3D
Outline
Access Guide
Query personal information
Query friends' information
Add QQ friends
FAQ
Android
Outline
Access Guide
Query Personal information
Query friends' information
Add QQ friends
FAQ
IOS
Outline
Access Guide
Query Personal information
Query friends' information
Add QQ friends
FAQ
Others
Data Structure
System Tools
Relation chain / Unity3D / Outline

Outline

The relation chain module is an information query service which is provided by MSDK and is based on mobile QQ and WeChat friends' relations. The relation chain module provides the following functions:

relation_process.png

1). Query the personal information (PersonInfo): nickname (nickname), OpenId(openId), small avatar 40x40(pictureSmall), mid-sized avatar 60x60(pictureMiddle), large avatar 100x100(pictureLarge)

Note: Due to the restriction of mobile QQ, avatar returns only two sizes 40x40 and 100x100, and the setting of mobile QQ is that mi-sized avatar also returns 40x40

2)Query friends' information:only support to query the information of friends who have played the current game. The detailed information of each friend is the same with his or her personal detailed information(PersonInfo)

3)Add QQ friends: You can complete the function of adding friends in the game through the interfaceAdd QQ friends

You can use the function of querying personal information and querying friends' information in the following scenes:

4)Game leaderboard(take the friends leaderboard of "Sword Heroes Fate" as an example)

QQ friends leaderboard calling interface: WGQueryQQGameFriendsInfo

Function 1: Call WGQueryQQGameFriendsInfo to get the data of QQ game friends

Function 2: Gift: which is a backend sharing function. Its feature is to be able to directly share messages to friends through the server without launching mobile QQ. For details, you can refer to the Share Module's "mobile QQ backend sharing"

Function 3: game entrance for mobile QQ game friends

Function 4: invite friends: which is a sharing function to share messages to QQ session. For details, please refer to the Share Module's "QQ structured sharing"

WeChat friends leaderboard calling interface: WGQueryWXGameFriendsInfo

Function 1: Call WGQueryWXGameFriendsInfo to get the data of WeChat game friends

Function 2: Gift: which is a backend sharing function. Its feature is to be able to directly share messages to friends through the server without launching WeChat. For details, please refer to the Share Module's "WeChat backend sharing"

Function 3: game entrance for WeChat friends

Function 4: invite friends: which is a sharing function to share messages to WeChat session. For details, please refer to the Share Module's " WeChat structured sharing"

5)Add qq friends

Access Guide

1 Preconditions

1)You have completed initialization according to the initialization module's description initialization

2)Confirm that the user has completed mobile QQ/WeChat authorized login

2 Refer to demos

1) For mobile QQ friend examples, refer to Assets\Example\MsdkDemo.cs script's ShowQQ() method.

2) For WeChat friend examples, refer to Assets\Example\MsdkDemo.cs script's ShowWX() method.

3 Bind the interface with button

For how to bind the interface with the button, refer to the login module Access Guide Step3. An example on how to call the relation chain interface is shown as follows:

using UnityEngine;
using System.Collections;
// Step1 Import MSDK libraries
using Msdk; 

public class ClickTest : MonoBehaviour {

    void Start () {
        // Step2 Set whether or not to use the PC debugging pile environment
        WGPlatform.SetPCDebug(true);
        // Step3 Set MSDK relation chain callback
        MsdkEvent.Instance.RelationEvent += RelationCallback;
        // Step4  Initialize MSDK
        WGPlatform.Instance.Init();
    }

    // the method which Button needs to bind; its name is optional
    public void Clicked()
    {
        // click the button and then call MSDK to get QQ game friend interface
       WGPlatform.Instance.WGQueryQQGameFriendsInfo();
    }

    // MSDK relation chain callback
    public void RelationCallback(RelationRet ret)
    {
        // Query the relation chain successfully
        switch (ret.type)
            {
                case (int)eRelationRetType.eRet_QueryMyInfo:
                    // personal information
                    break;
                case (int)eRelationRetType.eRet_QueryGameFriends:
                    // Friend's information
                    break;
            }
    }
}

4 Run and view the result

For how to run and check the result, refer to the login module Access Guide Step4

5 Call this module's other interfaces

1)Query personal information : Query mobile QQ WeChat user's personal information .

2)Add QQ friends: Allow the user to call msdk interface to add QQ friends in the game.

Query personal information

1. General description

1) Mobile QQ user (WGQueryQQMyInfo): After the user is authorized via mobile QQ, the game requires the user's nickname, avatar and other information and can call WGQueryQQMyInfo to get the user's personal information, including: nickname, openId, small avatar (PictureSmall), mid-sized avatar (pictureMiddle), and large avatar (pictureLarge).

2)After the WeChat user (WGQueryWXMyInfo) has authorized via WeChat, the game needs the user's personal information like his or her nickname and avatar. WGQueryWXMyInfo can be called. Here, the personal information includes: nickname (nickname), OpenId( openId), small avatar (pictureSmall), mid-sized avatar (pictureMiddle), large avatar (pictureLarge).

2.Registration callback

1)Function description

In order to receive msdk's relation chain callback, the game needs to register callback function for processing. It is recommended to register it in the game's Awake function

2)Interface declaration
public delegate void RelationDelegate(RelationRet ret);
3)Parameter description

None

4)Return value
return value name type description
ret RelationRet relation chain struct
5)Demo code
MsdkEvent.Instance.RelationEvent += (RelationRet ret) => {
    Debug.Log(ret.ToString());
    if (ret.flag == eFlag.eFlag_Succ) {
        // Query the relation chain successfully
    } else {
        // Query the relation chain unsuccessfully
    }
};
6)Special description

The personal information doesn't contain OpenId information. If you need OpenId information, you can get it through the login module's token-getting interface WGGetLoginRecord. The callback of querying personal information and the callback of querying a game friend's info can be distinguished via RelationRet.type.

7)Term interpretation

None

3、Call interfaces

1)Function description

The game can query the personal information by calling WGQueryQQMyInfo/WGQueryWXMyInfo interface, so as to get nickname(nickname), OpenId( openId), small avatar 40x40(pictureSmall), mid-sized avatar 60x60(pictureMiddle), large avatar 100x100(pictureLarge)

2)Interface declaration
Viod WGQueryQQMyInfo();
Viod WGQueryWXMyInfo();
3)Parameter description

None

4)Return value

None, the result is called back through RelationEvent. As for callback settings, please refer to Registration Callback

5)Demo code
WGPlatform.Instance.WGQueryQQMyInfo(); // query mobile QQ user's personal information 
WGPlatform.Instance.WGQueryWXMyInfo(); // query WeChat user's personal information
6)Special description

The personal information doesn't contain OpenId information. If you need OpenId information, you can get it through the login module's token-getting interface WGGetLoginRecord.

7)Term interpretation

None

Query game friends' information

1. General description

1) Mobile QQ user (WGQueryQQGameFriendsInfo) After the user gets authorization through mobile QQ, the user can get friends' information (such as friends' score leaderboard ) in the game through WGQueryQQGameFriendsInfo. As for friends' information, please refer to the personal information

2)WeChat user (WGQueryWXGameFriendsInfo) After the user gets authorization through WeChat, the user can get friends' information (such as friends' score leaderboard ) in the game through WGQueryWXGameFriendsInfo. As for friends' information, please refer to the personal information

2. Registration callback

This interface and the personal information query interface use the same callback. If the callback has been set, it is not needed to repeat setting it. If the callback is not set, please check if the callback setting RelationRet object's persons attribute is a List, in which each PersonInfo object is a friend's information. A friend's information includes: nickname, openId, small avatar 40x40(pictureSmall), mid-sized avatar 60x60(pictureMiddle), large avatar 100x100(pictureLarge).

3、Call interfaces

1)Function description

The game can query and get the information of friends playing the current game through CallWGQueryQQGameFriendsInfo/WGQueryWXGameFriendsInfo interface: nickname, openId, small avatar 40x40 (pictureSmall), mid-sized avatar 60x60 (pictureMiddle), large avatar 100x100 (pictureLarge).

2)Interface declaration
Void WGQueryQQGameFriendsInfo();
Void WGQueryWXGameFriendsInfo();
3)Parameter description

None

4)Return value

None, the result is called back through RelationEvent. As for callback settings, please refer to Registration Callback

5)Demo code
WGPlatform.Instance.WGQueryQQGameFriendsInfo(); // query the information about mobile QQ user's game friends
WGPlatform.Instance.WGQueryWXGameFriendsInfo(); // query the information about WeChat user's game friends
6)Special description

1) In order to prevent the failure of getting the personal information (such as avatar, name), friends' information (such as avatar, name) from resulting in the failure of logging in the game, please set querying the personal information and querying friends' information as the non-critical path.

2)In mobile QQ, the result of querying game friends' does not contain the user's own information; but in WeChat, the result contains the user's own information.

3)V3.3.21 version starts adding the user's unauthorized error codes in the relationship callback interface;if the user does not authorize the relationship permission, then relationRet.flag = eFlag_UnPermission (-9) in the callback interface OnRelationNotify.

4)Starting from version V3.3.28 `WGQueryWXGameFriendsInfo` the client interface of WeChat in-game friend information retrieval function, adds returning the `friendRemark` (remark name) field.

The test environment and release environment of MSDK V3 are compatible with the old scheme by default (`nickname` gives priority to using WeChat friend remarks and does not return the `friendRemark` field). If the game needs to switch to the new scheme (`nickname` corresponds to WeChat nickname, and `friendRemark` corresponds to WeChat in-game friend remarks), it needs to contact MSDK to update the configuration for the game to enable the new scheme.

7)Term interpretation

Game friends: players who are playing the current game 

Non-critical path: refer to a saying of not affecting the game's login process; MSDK defines mobile QQ\WeChat's login process as the critical path. Once the login process is interrupted, this will cause a serious impact on the normal operation of the game.

Add QQ friends

1)General description

The player may directly add (Pull mobile QQ) game player into QQ friends during the game (in case of multiple clicks, multiple pieces of QQ adding applications will not be sent).

2)Registration callback

None

3)Call interfaces

1)Function description

Players can directly add other players as QQ friends in the game.

2)Interface declaration
void WGAddGameFriendToQQ(string fopenid, string desc, string message);
3)Parameter description
Parameter name Type Description
fopenid string to-be-added friend's openid
desc string to-be-added friend's remarks
message string authentication information sent when adding a friend
4)Return value

None

5)Demo code
string openID = "44386ABB2C583E72CF436D3FAD31B323";
WGPlatform.Instance.WGAddGameFriendToQQ (openID, "Broken kite", "Hello, I am a player of the King of Glory: Mr. Liu");
6)Special description

None

7)Name interpretation

None

FAQ

|FAQ|relation chain|Unity3D|