NAV
Unity Unreal Engine 4

GS2-News

GS2-SDK for Game Engine のリファレンス

ゲームエンジン向けSDK

モデル

EzNews

説明
section string セクション名
content string コンテンツ名
title string 記事見出し
scheduleEventId string イベントGRN
timestamp long タイムスタンプ
frontMatter string Front Matter

EzSetCookieRequestEntry

説明
key string 記事を閲覧できるようにするために設定してほしい Cookie のキー値
value string 記事を閲覧できるようにするために設定してほしい Cookie の値

メソッド

getContentsUrl

getContentsUrl

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->news.wantGrant(
    [](gs2::ez::account::AsyncEzWantGrantResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "news.wantGrant failed.");
        }
        else
        {
            Items = r.getResult()->getItems();
            BrowserUrl = r.getResult()->getBrowserUrl();
            ZipUrl = r.getResult()->getZipUrl();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1") // namespaceName
);

///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////

using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);

// Up to this line is the initialization process.

{
    var domain = gs2.News.Namespace(
        namespaceName: "namespace1"
    ).Me(
        gameSession: gameSession
    ).News(
    );
    var result = await domain.GetContentsUrlAsync(
    );
    var item = await result.ModelAsync();
    var browserUrl = result.BrowserUrl;
    var zipUrl = result.ZipUrl;
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////

using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}
var gs2 = new Gs2.Unity.Client(profile);

// Up to this line is the initialization process.

{
    AsyncResult<EzGetContentsUrlResult> asyncResult = null;
    var current = gs2.News.GetContentsUrl(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var items = result.Items;
    var browserUrl = result.BrowserUrl;
    var zipUrl = result.ZipUrl;
}

お知らせ記事へのアクセスに設定が必要なクッキーのリストを取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペースの名前
accessToken string ~ 128文字 ユーザーID

Result

説明
items List<EzSetCookieRequestEntry> お知らせコンテンツにアクセスするために設定の必要なクッキーのリスト
browserUrl string お知らせコンテンツにアクセスするためのURL
zipUrl string ZIP形式のお知らせコンテンツにアクセスするためのURL / アクセスにCookieの設定は不要

listNewses

listNewses

ProfilePtr = std::make_shared<gs2::ez::Profile>(
    TCHAR_TO_ANSI(*ClientId),
    TCHAR_TO_ANSI(*ClientSecret),
    gs2::ez::Gs2BasicReopener()
);

ClientPtr = std::make_shared<gs2::ez::Client>(
    *ProfilePtr
);

ProfilePtr->initialize(
    [this](gs2::ez::Profile::AsyncInitializeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
        }
        else
        {
            AccountCreate();
        }
    }
);

// Up to this line is the initialization process.

ClientPtr->news.describeNews(
    [](gs2::ez::account::AsyncEzDescribeNewsResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "news.describeNews failed.");
        }
        else
        {
            Items = r.getResult()->getItems();
            ContentHash = r.getResult()->getContentHash();
            TemplateHash = r.getResult()->getTemplateHash();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1") // namespaceName
);

///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////

using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);

// Up to this line is the initialization process.

{
    var domain = gs2.News.Namespace(
        namespaceName: "namespace1"
    ).Me(
        gameSession: gameSession
    );
    var items = await domain.NewsesAsync(
    ).ToListAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////

using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;

var profile = new Profile(
    clientId: "your client id",
    clientSecret: "your client secret",
    reopener: new Gs2BasicReopener()
);

{
    AsyncResult<object> asyncResult = null;

    var current = profile.Initialize(
        r => { asyncResult = r; }
    );

    yield return current;

    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }
}
var gs2 = new Gs2.Unity.Client(profile);

// Up to this line is the initialization process.

{
    AsyncResult<EzListNewsesResult> asyncResult = null;
    var current = gs2.News.ListNewses(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var items = result.Items;
    var contentHash = result.ContentHash;
    var templateHash = result.TemplateHash;
}

お知らせ記事の一覧を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペースの名前
accessToken string ~ 128文字 ユーザーID

Result

説明
items List<EzNews> お知らせ記事のリスト
contentHash string お知らせ記事データのハッシュ値
templateHash string テンプレートデータのハッシュ値