在VB .Net中使用pastebin API

时间:2011-09-27 17:23:58

标签: vb.net api pastebin

我遇到一个小问题,我刚刚从公共Pastebin API更改为新API。我收到了无效的api错误:API请求错误,api_option无效

这是我的代码:

Dim Exposure As Integer = 0
        System.Net.ServicePointManager.Expect100Continue = False
        If ComboBox1.Text = "Public" Then
            Exposure = 0
        Else
            Exposure = 1
        End If
        Dim fi As String = "?api_paste_private=" & Exposure & "&api_paste_format=" & ComboBox2.Text & "&api_paste_expire_date=" & ComboBox3.Text & "&api_dev_key=CENSORED" & "&api_paste_code=" & code
        Dim w As New System.Net.WebClient()
        w.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
        Dim pd As Byte() = System.Text.Encoding.ASCII.GetBytes(fi)
        Dim rd As Byte() = w.UploadData("http://pastebin.com/api/api_post.php", "POST", pd)
        Dim r As String = System.Text.Encoding.ASCII.GetString(rd)
        TextBox6.Text = r
        Return r

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:2)

您必须在请求中添加api_option=paste,如下所示:http://pastebin.com/api#2