Partage
  • Partager sur Facebook
  • Partager sur Twitter

C# Récupéré des donner Json d'un website (api)

    3 janvier 2020 à 14:46:30

    j'ésaille de récupéré des donner mais jais un problème

    je n'arrive pas a récupéré des donner car je ne sais pas comment ouvrir "player" pour enchuite aller chercher uuid par exemple. j’ai trouver des vidéo expliquant comment faire mais je n'es pas comprit je vous demande donc de l'aide ici

    J'utilise Visual Studio 2019 / C# Window Form

    Il y a beaucoup de donner JSON mais je ne pas besoin de tout

    Voici la page entière

    *Le code est trop grand donc je l'es mi sur un site web*

    Le site Web (.txt)

    Le Site Web (.json) (Defauld)

    Voici mon code pour le Form

    using Newtonsoft.Json;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Net;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace Hypixel_Stats
    {
        public partial class HypixelStats : Form
        {
            public HypixelStats()
            {
                InitializeComponent();
            }
    
            private void getinfo_button_Click(object sender, EventArgs e)
            {
                // HYPIXEL API KEY
    // je donne pas la clé x')
                //end
                var client = new WebClient();
                var link = client.DownloadString("https://api.hypixel.net/player?key=PUT_KEY_HERE&name=" + username_txtbox.Text);
                hypixelStats_get postMethod = JsonConvert.DeserializeObject<hypixelStats_get>(link);
    
    
                // set values
    
                label1.Text = "Username : " + postMethod.playername;
                
    
    
                // var request1 = client.DownloadString("https://thumbnails.roblox.com/v1/users/avatar-headshot?userIds="+postMethod.Id+"&size=48x48&format=Png");
                // robloxaccoundinfo_post postMethod2 = JsonConvert.DeserializeObject<robloxaccoundinfo_post>(request1);
                // pictureBox1.Load(postMethod2.imageUrl);
                #region Player Get Head
                //var request = WebRequest.Create("https://cravatar.eu/head/" + username_txtbox.Text);
    
                //using (var response = request.GetResponse())
                // using (var stream = response.GetResponseStream())
                // {
                //   userHeadimage.Image = Bitmap.FromStream(stream);
                // }
                #endregion
            }
        }
    }

    Et voicie le code du 2e doccument 'hypixelStats_get.cs'

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace Hypixel_Stats
    {
        class hypixelStats_get
        {
            public string playername { get; set; }
            public string uuid { get; set; }
    
        }
    }
    

    Voila ! Merci de votre future aide



    -
    Edité par MédrickM 3 janvier 2020 à 16:57:49

    • Partager sur Facebook
    • Partager sur Twitter
      4 janvier 2020 à 22:54:30

      Vous êtes sûr de votre classe ???

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
       
      namespace Hypixel_Stats
      {
          class player
          {
              public string playername { get; set; }
              public string uuid { get; set; }
              ...
          }
      
          class hypixelStats_get
          {
              public string success { get; set; }
              public player player { get; set; }
          }
      ...
      }



      -
      Edité par bacelar 4 janvier 2020 à 22:56:11

      • Partager sur Facebook
      • Partager sur Twitter
      Je recherche un CDI/CDD/mission freelance comme Architecte Logiciel/ Expert Technique sur technologies Microsoft.
        7 janvier 2020 à 10:23:51

        >Non ca ne marche pas :/

        C'est un peu court, jeune homme !

        • Partager sur Facebook
        • Partager sur Twitter
        Je recherche un CDI/CDD/mission freelance comme Architecte Logiciel/ Expert Technique sur technologies Microsoft.

        C# Récupéré des donner Json d'un website (api)

        × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
        × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
        • Editeur
        • Markdown