Share
If you were looking for the method for use with Unreal Engine, see Share for Unreal Engine SDK.
Shares a message to the user's feed, such as a Facebook timeline. If the user is already logged in, the channel parameter can be left empty.
System channel supports sharing text, links, and images at the same time. For the System channel, the sharing screen provided by the OS is opened for the user to share the content to an installed app that has implemented the system share function.
Function definition
public static void Share(INTLFriendReqInfo info, string channel = "");
Input parameters
Parameter | Type | Description |
---|---|---|
info | INTLFriendReqInfo | Friend module request body Including the request object, request information, and other important parameters. |
channel | string | Channel definition Example: "Facebook" |
Return value
No return value.
Observers
The callback processing interface is FriendBaseResultObserver.
The callback data structure is BaseResult.
The callback methodID is INTL_FRIEND_SHARE
.
Code sample
For more information on supported channels, see Friend Sharing Content.
(1) Share text
var reqInfo = new INTLFriendReqInfo
{
Type = FriendReqType.Friend_REQ_TEXT,
Description = "INTL description"
};
INTLAPI.Share (reqInfo, INTLChannel.System);
(2) Share links
var reqInfo = new INTLFriendReqInfo
{
Type = FriendReqType.Friend_REQ_LINK,
Link = "https://www.facebook.com/link"
};
INTLAPI.Share (reqInfo, INTLChannel.Facebook);
(3) Share pictures
var reqInfo = new INTLFriendReqInfo
{
Type = FriendReqType.Friend_REQ_IMAGE,
ImagePath = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png";
};
INTLAPI.Share (reqInfo, INTLChannel.Facebook);
(4) Share text, link, and image simultaneously
var reqInfo = new INTLFriendReqInfo
{
Type = FriendReqType.Friend_REQ_IMAGE,
Description = "INTL Description",
Link = "https://www.facebook.com/link",
ImagePath = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
};
INTLAPI.Share (reqInfo, INTLChannel.System);
(5) Share videos
var reqInfo = new INTLFriendReqInfo
{
Type = FriendReqType.Friend_REQ_VIDEO,
MediaPath = "/path/to/video"
};
INTLAPI.Share (reqInfo, INTLChannel.Facebook);
Data structure
INTLFriendReqType: friend request type
public enum INTLFriendReqType
{
Friend_REQ_TEXT = 10000, //Share text
Friend_REQ_LINK, //Share link
Friend_REQ_IMAGE, //Share image
Friend_REQ_INVITE, //Send invite
Friend_REQ_VIDEO, //Share video
}
INTLFriendReqInfo: friend information
Member variable | Type | Description | Remark |
---|---|---|---|
Type | int | Friend Request Type (INTLFriendReqType) | Required when sharing messages, not required when adding friends. |
User | string | Can be ID or OpenID, users need to fill in the OpenID of the specified friend | Required |
Title | string | Share title | Required |
Description | string | Outline, briefly describe the purpose of sharing | Optional |
ImagePath | string | Image can be local address or URL, local address is recommended | Optional |
ThumbPath | string | Thumbnail, usually the icon of the game, either a local icon or an icon URL, it is recommended to use a local address | Optional |
MediaPath | string | Multimedia (music or video), only supports local address | Optional |
Link | string | Shares the link, which can be a picture, music, video or jump link, | Optional |
ExtraJson | string | Extended field | Optional |