question

brendan avatar image
brendan asked

what's correct query api ?

rynosce
started a topic on Tue, 27 January 2015 at 3:05 AM

Hello ?

whats is correct query API ?

my script :

    IEnumerator LoadAccountPlayFab()

    {

  // https://XXXX.playfabapi.com/Client/LoginWithPlayFab?TitleId=XXXX&Username=XXXXXXXXXX&Password=XXXXXXXXXX&PublisherId=1

  WWW temp = new WWW("https://" + TitleId + ".playfabapi.com/Client/LoginWithPlayFab?TitleId=" + TitleId + "&Username=" + inputLogin + "&Password=" + inputLogin + "&PublisherId=1");

        yield return temp;

        if (temp.error != null)

        {

            Debug.Log("Error connect PlayFab");

        }

        else

        {

   if (temp.text == "0")

   {

    Debug.Log("Success");

    _LoadAccountPlayFab = true;

    StartCoroutine(LoadAccPlayFab());

   }

            else if (temp.text == "1") Debug.Log("Unknown");

            else if (temp.text == "1000") Debug.Log("InvalidParams");

            else if (temp.text == "1001") Debug.Log("AccountNotFound");

            else if (temp.text == "1002") Debug.Log("AccountBanned");

            else if (temp.text == "1003") Debug.Log("InvalidUsernameOrPassword");

            else { Debug.Log("Other error"); }

        }

    }

no resultat !

i open browse link

https://XXXX.playfabapi.com/Client/LoginWithPlayFab?TitleId=XXXX&Username=XXXXXXXXXX&Password=XXXXXXXXXX&PublisherId=1

page response clear page !

what correct send query ?

I do not understand the standard library PlayFab+Unity3D !

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

·
brendan avatar image
brendan answered

Best Answer
Brendan Vanous said on Thu, 29 January 2015 at 1:11 AM

The title Catalog can be retrieved with the GetCatalogItems API call.

The player's inventory can be retrieved with the GetUserInventory API call.

Both are available in the PlayFabClientAPI of the UnitySDK:

https://github.com/PlayFab/UnitySDK/blob/84a73473570410e3e61ecb7c374efedff11b91d1/PlayFabClientSDK/Playfab/PlayFabSDK/Public/PlayFabClientAPI.cs

And in the PlayFabMarketMeny and PlayFabItemsController examples in our SDK, you'll also see an examples of how to use these simply:

https://github.com/PlayFab/UnitySDK/blob/1cb6d4428824aa4ec5d7a2e67489afe60b96ddb0/PlayFabClientSDK/Playfab/Examples/Scripts/PlayFabMarketMenu.cs

https://github.com/PlayFab/UnitySDK/blob/1cb6d4428824aa4ec5d7a2e67489afe60b96ddb0/PlayFabClientSDK/Playfab/Examples/Scripts/PlayFabItemsController.cs

For your other post, could you be specific about what information you received that you believe was incorrect? Reviewing this thread, we've provided very specific pointers to the correct way to use these API calls.


11 Comments
Brendan Vanous said on Tue, 27 January 2015 at 4:57 PM

If you want to compose the REST calls directly, you would need to format them using JSON body data. I've attached an example of a few calls as a Postman collection, with instructions on how to set your environment variables for testing. Please note that Publisher IDs need to be requested via devrel@playfab.com currently. Since each is to be used exclusively by an owner (developer or publisher) of titles, we cannot let them be freely specified, as that runs the risk of collision between IDs. We will add a request for Publisher IDs to the Game Manager in an upcoming update.

Alternately, if you would like to make the calls using our UnitySDK, you would simply use the API calls as specified in that SDK. You can find all the Client calls, for example, in the PlayFabClientSDK folder. The call format is the same as for the Web API calls, with the inputs wrapped in a "...Request". So for instance, the data you would input to RegisterPlayFabUser in the Web API call is in RegisterPlayFabUserRequest.


rynosce said on Wed, 28 January 2015 at 1:47 AM

You that I do not understand ?


rynosce said on Wed, 28 January 2015 at 1:50 AM

Your UnitySDK not clear at all !

how to loading information about the player ?

I've added new things as I get them ?


deadstarcgs said on Wed, 28 January 2015 at 4:01 AM

If you're having trouble combining PlayFab and Unity, I highly recommend looking through the PlayFab Angry Bots Example, it certainly cleared up a lot of things for me.


rynosce said on Wed, 28 January 2015 at 4:01 AM

how send query ?

POST https://[TitleID].playfabapi.com/Client/LoginWithPlayFab
Content-Type: application/json;
{
  "TitleId": "1",
  "Username": "theuser",
  "Password": "thepassword",
  "PublisherId": "1"
}

rynosce said on Wed, 28 January 2015 at 1:21 PM

I found how to send a request without UnitySDK !

Login.cs

using UnityEngine;

using System.Collections;



using System.Collections.Generic;

using System;



public class Login: MonoBehaviour

{

    string url = "https://XXXX.playfabapi.com/Client/LoginWithPlayFab";

    string response = "";

    string query = "{ \"TitleId\": \"XXXX\", \"Username\": \"XXXXXXXXXX\", \"Password\": \"XXXXXXXXXX\", \"PublisherId\": \"1\" }";



    void OnGUI()

    {

        url = GUI.TextField(new Rect(5, 5, Screen.width - 85, 20), url);

        if (GUI.Button(new Rect(Screen.width - 75, 5, 70, 20), "Query")) StartCoroutine(Query());

        query = GUI.TextField(new Rect(5, 30, Screen.width - 10, Screen.height / 2 - 32.5f), query);

        response = GUI.TextField(new Rect(5, Screen.height / 2 + 2.5f, Screen.width - 10, Screen.height / 2 - 7.5f), response);

    }



    private IEnumerator Query() // string url, string data, string authType, string authKey

    {



        byte[] bData = System.Text.Encoding.UTF8.GetBytes(query);



        Dictionary<string, string> headers = new Dictionary<string, string>();

        headers.Add("Content-Type", "application/json");

        // if (authType != null) headers.Add(authType, authKey);

        headers.Add("X-ReportErrorAsSuccess", "true");

        headers.Add("X-PlayFabSDK", "UnitySDK-1.2.0-1.0.4");



        WWW www = new WWW(url, bData, headers);

        yield return www;



        if (!String.IsNullOrEmpty(www.error)) // www.error != null

        {

            response = www.error;

        }

        else

        {

            response = www.text;

        }



    }

}

how is correct sorting information ?


rynosce said on Wed, 28 January 2015 at 1:35 PM

deadstarcgs I do not use UnitySDK

curve and it did not finish it and buggy !

I can not understand how a UnitySDK AngryBots

information is received

send is informations

as I read that, I added inventory

there is no normal documentation

and she very a lot of bugs !

I downloaded and installed and it does not work the first time !

it is a failure !

I write functional and methods from the beginning !

with a clean slate !

I want stability and quality !

now left to learn this information to sort and record the values in certain variables!


Brendan Vanous said on Wed, 28 January 2015 at 1:37 PM

Correct, you can manually format your Web API calls directly, or (if you're using Unity) you can just use our UnitySDK API calls which wrap those calls and manage the HTTP on your behalf. For LoginWithPlayFab, for example, the MiniExample in our UnitySDK shows how to make this call directly (have a look at the source for the full details):

PlayFabClientAPI.LoginWithPlayFab (new LoginWithPlayFabRequest { Username = "Bob", Password = "nose" }, OnLoginResult, null);

For your other question, what is it you're looking to sort?

As to your other post, we have quite a few developers using the UnitySDK successfully. If you're seeing any bugs, we'd appreciate it if you could provide specifics, including repro cases if at all possible. Thanks!


rynosce said on Thu, 29 January 2015 at 12:54 AM

1) I can not figure out how to get the information that is in invetore Player ?

2) how to get the information catalog ?

i add new item for catalog :

Catalog : Knife

ID: 1001 -> Name: knife1

ID: 1002 -> Name: knife2

ID: 1003 -> Name: knife3

ID: 1004 -> Name: knife4

ID: 1005 -> Name: knife5

Catalog : Pistol

ID: 2001 -> Name: pistol1

ID: 2002 -> Name: pistol2

ID: 2003 -> Name: pistol3

ID: 2004 -> Name: pistol4

ID: 2005 -> Name: pistol5

Catalog : Weapon

ID: 3001 -> Name: weapon1

ID: 3002 -> Name: weapon2

ID: 3003 -> Name: weapon3

ID: 3004 -> Name: weapon4

ID: 3005 -> Name: weapon5

Unity3D :

i create static script :

database.cs

{

 public static string Name = "";

 public static int Kills = 0;

 public static int GC = 0;





 public static bool knife1 = true; // standalone

 public static bool knife2 = false;

 public static bool knife3 = false;

 public static bool knife4 = false;

 public static bool knife5 = false;





 public static bool pistol1 = true; // standalone

 public static bool pistol2 = false;

 public static bool pistol3 = false;

 public static bool pistol4 = false;

 public static bool pistol5 = false;





 public static bool weapon1 = true; // standalone

 public static bool weapon1 = false;

 public static bool weapon1 = false;

 public static bool weapon1 = false;

 public static bool weapon1 = false;

}

how is loading information catalog ?

how is get information inventory player ?

how is player inventory install for database.cs ?

example script sort info

LoadInventory.cs

string[] temp = temp.text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

for (int x = 0; x < temp.Length; x++) 

{

if (temp[x].IndexOf("DisplayName=") == 0) database.Name = temp[x].Remove(0, 12);

else if (temp[x].IndexOf("Kills=") == 0) database.Kills = temp[x].Remove(0, 6);

else if (temp[x].IndexOf("GC=") == 0) database.GC = temp[x].Remove(0, 3);

else if (temp[x] == "knife1=true") database.knife1 = true;

else if (temp[x] == "knife2=true") database.knife1 = true;

else if (temp[x] == "knife3=true") database.knife1 = true;

else if (temp[x] == "knife4=true") database.knife1 = true;

else if (temp[x] == "knife5=true") database.knife1 = true;

else if (temp[x] == "pistol1=true") database.pistol1 = true;

else if (temp[x] == "pistol2=true") database.pistol2 = true;

else if (temp[x] == "pistol3=true") database.pistol3 = true;

else if (temp[x] == "pistol4=true") database.pistol4 = true;

else if (temp[x] == "pistol5=true") database.pistol5 = true;

else if (temp[x] == "weapon1=true") database.weapon1 = true;

else if (temp[x] == "weapon2=true") database.weapon2 = true;

else if (temp[x] == "weapon3=true") database.weapon3 = true;

else if (temp[x] == "weapon4=true") database.weapon4 = true;

else if (temp[x] == "weapon5=true") database.weapon5 = true;

}

I can not understand how to take the information and sort it ?


rynosce said on Thu, 29 January 2015 at 1:07 AM

In general, I could not understand anything in this mess UnituSDK !

where documentation as to send and receive information through UnitySDK ?

when I asked how to send an inquiry

I was told all wrong !

I had to come up with a script !

Here all people stupid ?

WTF ???????

you can finally explain to me how to get information from the catalog and player ?


Brendan Vanous said on Thu, 29 January 2015 at 1:11 AM

The title Catalog can be retrieved with the GetCatalogItems API call.

The player's inventory can be retrieved with the GetUserInventory API call.

Both are available in the PlayFabClientAPI of the UnitySDK:

https://github.com/PlayFab/UnitySDK/blob/84a73473570410e3e61ecb7c374efedff11b91d1/PlayFabClientSDK/Playfab/PlayFabSDK/Public/PlayFabClientAPI.cs

And in the PlayFabMarketMeny and PlayFabItemsController examples in our SDK, you'll also see an examples of how to use these simply:

https://github.com/PlayFab/UnitySDK/blob/1cb6d4428824aa4ec5d7a2e67489afe60b96ddb0/PlayFabClientSDK/Playfab/Examples/Scripts/PlayFabMarketMenu.cs

https://github.com/PlayFab/UnitySDK/blob/1cb6d4428824aa4ec5d7a2e67489afe60b96ddb0/PlayFabClientSDK/Playfab/Examples/Scripts/PlayFabItemsController.cs

For your other post, could you be specific about what information you received that you believe was incorrect? Reviewing this thread, we've provided very specific pointers to the correct way to use these API calls

10 |1200

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

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.