不确定如何在vb中发送api auth密钥

时间:2018-03-09 21:06:46

标签: vb.net

我正在尝试为Fortnite Battle Royale制作一个小型统计检查应用程序。 TRN Api需要发送密钥,我不知道该怎么做。提前谢谢。

Public Class Form1


Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
    Me.Close()
End Sub

Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
    Dim webClient As New System.Net.WebClient
    Dim Platform As String = ""
    Dim UName As String = ""
    Dim TRNApiKey As String = "f4d79aad-381b-4b91-87f1-2a1c2ee14cb6"
    Dim fortniteStatslookup As String
    Dim URL As String

    Select Case cboPlatform.Text
        Case = "PC"
            Platform = "pc"
        Case = "Xbox"
            Platform = "xbl"
        Case = "Playstation"
            Platform = "psn"
    End Select

    UName = txtUName.Text

    URL = "https://api.fortnitetracker.com/v1/profile/" & Platform & "/" & UName

    webClient.Headers.Add("f4d79aad-381b-4b91-87f1-2a1c2ee14cb6", URL)
    fortniteStatslookup = webClient.DownloadString(URL)

    txtOutput.Text = fortniteStatslookup
End Sub

End Class

1 个答案:

答案 0 :(得分:1)

请参阅:MSDN Webclient.Headers documentation

System.Net.WebClient.Headers采用键值对,因此您需要以下内容:

webClient.Headers.Add("key", "f4d79aad-381b-4b91-87f1-2a1c2ee14cb6")

webClient.Headers.Add("APIkey", "f4d79aad-381b-4b91-87f1-2a1c2ee14cb6")