question

digitalmkt avatar image
digitalmkt asked

GetTitleNews coding help

Hi Guys, I'm following the instructions I found at https://api.playfab.com/docs/tutorials/landing-content/title-news and I'm still stuck understanding how to get the Title, body and timestamp entries. I'm know it looks quite simple but I don't know how to do it. Do you have any referente code to make it work?

I can have the entries and I tried lots of possibilities to populate the variables with the API call entries and the result is coding errors.

Here is my code:

voidReadTitleNews()
{
PlayFabClientAPI.GetTitleNews(newGetTitleNewsRequest()
{
Count=1,

},result=>
{

GetTitleNewsResultnewsResult=newTitleNewsItem()
{
Timestamp=
Body=
Title=

}

},error=>Debug.LogError(error.GenerateErrorReport()));
}

}

Thanks a lot for your help.

Title News
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Hernando avatar image
Hernando answered

Title, Body, and Timestamp will be contained in the callback, so you can get them from variable"result" in the code you posted. The following code demonstrates how to use it:

    void ReadTitleNews()

    {

        PlayFabClientAPI.GetTitleNews(new GetTitleNewsRequest(){

            Count = 1 },result =>

        {

            Debug.Log("Timestamp :" + result.News[0].Timestamp);

            Debug.Log("Title :" + result.News[0].Title);

            Debug.Log("Body :" + result.News[0].Body);



        },

        error => Debug.LogError(error.GenerateErrorReport()));

    }
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

digitalmkt avatar image digitalmkt commented ·

Thank You @Hernando. It works with the Admin API checked.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.