0

blogger apiを使用して vb.net アプリケーションから新しい投稿を作成しようとしています。でも毎回失敗します。場合によっては 403 禁止エラーが返される場合もあります Unauthorized エラーが発生する場合もあります。助けてください。

 Dim mBlogID As String = "5861877551002158183"
    Dim AuthToken As String = "AIza......xxxx..........E6g"
    Dim post As String = "{""kind"": ""blogger#post"", ""blog"": { ""id"": """ & mBlogID & """}, ""title"": ""abc-title"", ""content"": ""abc-cont""}"
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create("https://www.googleapis.com/blogger/v3/blogs/" & mBlogID & "/posts?key=" & AuthToken), HttpWebRequest)


    request.Method = "POST"
    request.ContentLength = post.Length
    request.ContentType = "application/json"
    request.Headers.Add("Authorization: ", AuthToken) '<--- error here

    Using requestStream As Stream = request.GetRequestStream()
        Dim postBuffer As Byte() = Encoding.ASCII.GetBytes(post)
        requestStream.Write(postBuffer, 0, postBuffer.Length)
    End Using


    Using response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse) '<--- Unauthorised error or 403 error here
        Using responseStream As Stream = response.GetResponseStream()
            Using responseReader As New StreamReader(responseStream)
                'Dim json As String = responseReader.ReadToEnd()
                'Dim PostURL As String = Regex.Match(json, """url"": ?""(?<id>.+)""").Groups("id").Value
                MsgBox(json) 'want to read json response here.
                'MsgBox(PostURL)
            End Using
        End Using
    End Using

このコードは次のエラーを返します: 指定された値に無効な HTTP ヘッダー文字が含まれています。パラメータ名: 名前

誰でも修正できますか?ブロガーに新しい投稿を作成し、その URL を読みたいだけです。

プロジェクト情報:-

プラットフォーム: Visual Basic 2010

Blogger API バージョン: V3

4

1 に答える 1

0

このソリューションを表示することをお勧めします。投稿には完全な説明があります。

于 2014-04-28T17:42:27.923 に答える