我似乎无法获取或存储我创建的帖子消息的ID。我正在使用此代码发布消息:
Try
Dim fb = New FacebookClient(_accessToken)
AddHandler fb.PostCompleted, Function(o, e)
If (e.Cancelled) Then
ElseIf e.Error IsNot Nothing Then
MessageBox.Show(e.Error.Message)
Else
Dim result As Object = e.GetResultData()
_lastMessageId = result.Id
End If
Return MessageBox.Show("Message Posted successfully")
End Function
Dim parameters As Object = New ExpandoObject()
parameters.message = TextBox1.Text
fb.PostTaskAsync("me/feed", parameters)
MsgBox("This is the last message id " & _lastMessageId)
Catch ex As FacebookApiException
MessageBox.Show(ex.Message)
End Try
我只想存储发布的ID,以便稍后删除。
这是我想出的工作代码,感谢prabir
Dim fb = New FacebookClient(_accessToken)
Dim parameters As Object = New ExpandoObject()
parameters.message = "Testing"
Dim task = fb.PostTaskAsync("me/feed", parameters)
task.ContinueWith(Function(t)
If t.Exception Is Nothing Then
Dim result As Object = t.Result
_lastMessageId = result.id
Else
MsgBox("error occurred")
End If
Return t.Result
End Function)
答案 0 :(得分:0)
这里有c#代码,可以帮助你开始使用它。
由于您使用的是XTaskAsync方法,因此请使用ContinueWith而不是PostCompleted。
fb.PostTaskAsync("me/feed", parameters)
.ContinueWith(t= > {
if(!t.IsFaulted) {
dynamic result = t.Result;
}
});
XTaskAsync方法返回Task<object>