Imports System.Text ' Tutorial Teil 2: Facebook mit Visual Basic ' http://www.Frank-IT-Beratung.com/blog/ Public Class Form1 Private Sub cmdSenden_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSenden.Click Dim Nachricht, Antwort As Byte() Dim AccessToken As String AccessToken = txtAccessToken.Text If AccessToken = "" Then MsgBox("Bitte erst auf 'Login' klicken") Return End If 'postet die Nachricht auf der Wall des Users 'der das AccessToken generiert hat: Dim GraphURL As String = "https://graph.facebook.com/me/feed" 'WebClient anlegen Dim myWebClient As New Net.WebClient 'Except100 ausschalten, sonst gibt es u. U. Fehlermeldungen Net.ServicePointManager.Expect100Continue = False Nachricht = Encoding.UTF8.GetBytes("message=" & _ txtStatusupdate.Text & _ "&access_token=" _ & AccessToken) Try Antwort = myWebClient.UploadData(GraphURL, Nachricht) 'Erfolgsmeldung (ID des Posts) in JSON 'MsgBox(System.Text.Encoding.ASCII.GetString(Antwort)) MsgBox("Erfogreich gepostet!") Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub cmdLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogin.Click Dim u As String = "https://graph.facebook.com/oauth/authorize?" 'Anwendungs-ID u = u + "client_id=???" 'Berechtigung u = u + "&scope=publish_stream" 'URL, die nach Aufruf angezeigt wird u = u + "&redirect_uri=http://www.facebook.com/connect/login_success.html" 'Login-Typ u = u + "&type=user_agent" u = u + "&display=popup" WebBrowser1.Navigate(u) End Sub Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated 'der Access-Token hängt an der URL Dim q As String = WebBrowser1.Url.ToString() 'jetzt auslesen If q.Contains("#access_token=") Then q = q.Substring(q.IndexOf("access_token=") + 13) txtAccessToken.Text = q.Substring(0, q.IndexOf("&")) End If End Sub End Class