Upload Picture to wall

Apr 12, 2015 at 3:59 PM
Hi all.
Sorry for my bad english.

how can upload image to wall?
I send messages suceffully, but images gives me error:

(#100) source is not properly formatedd

I have also tried to "picture", but I get the same error.

My Code:

        Dim query = New Dictionary(Of String, String)()
        query("access_token") = MyToken
        query("message") = txtMensaje.Text
        query("source") = MyImagen

        Dim po As ComputerBeacon.Json.JsonObject
        po = Api.Post("/me/feed", query) 'enviar mensaje

        MsgBox("MENSAJE ENVIADO OK")

    Catch ex As Exception
    End Try
Apr 16, 2015 at 6:03 AM
Try a MultipartPost (http://computerbeacon.net/library/1n1dt49v82u83).

In the dictionary which sets the parameters, set other content using the StringContent class, and set the picture using the ByteArrayContent class (http://computerbeacon.net/library/ij34q7ldn3mn6). Match the parameters with Facebook's documentation (e.g. https://developers.facebook.com/docs/graph-api/reference/page/photos/#publish)

If I get time, I may post a complete code example in the next blog post.
Apr 23, 2015 at 3:47 AM
Thank you very much for your answer, I'll see what I can get.
I would greatly appreciate if you can add some piece of code.

Apr 23, 2015 at 7:54 AM
Hello again,
I uploaded a picture, thank you very much.

Now I have a new question:
it is possible to upload more than one image in the same post?

my code for upload one image:
Private Function GetImageArray(ByVal ImagePath As String) As Byte()
    GetImageArray = Nothing

    Dim img As Image = Image.FromFile(ImagePath)
    Dim imageConverter As New ImageConverter()

    Return DirectCast(imageConverter.ConvertTo(img, GetType(Byte())), Byte())
End Function

Private Sub SendPost()
        'Dim u = New Graph.User("me", MyToken)
        'PictureBox1.Load(String.Format("https://graph.facebook.com/{0}/picture?type={1}", u.Id, "large")) ''"square"))
        'Label1.Text = u.Name '+ vbCrLf + u.Id.ToString

        Dim _tkn, _msg As New StringContent()
        Dim _img As New ByteArrayContent()

        _tkn.Value = MyToken
        _msg.Value = txtMessage.Text
        _img.Bytes = GetImageArray(MyImagen)
        _img.ContentType = "image/jpeg"

        Dim query2 = New Dictionary(Of String, HttpContent)()
        query2("access_token") = _tkn
        query2("message") = _msg
        query2("picture") = _img
        'query2("picture2") = _img2

        Dim fr = FacebookRequest.CreateMultipartPost("/me/photos", query2)
        Dim resp As String = fr.GetResponse()

        MsgBox("MENSAJE ENVIADO OK: " + vbCrLf + vbCrLf + resp)

    Catch ex As Exception
    End Try
End Sub