1

可能重复:
如何检索我刚刚通过 Facebook API 发布的帖子的帖子 ID

我正在尝试使用 Facebook C# SDK,并希望在我将照片发布到墙上后找到用于在我的应用中显示照片的变量。我知道我需要找到照片的 ID,但我运气不佳。我尝试使用_lastMessageID但没有用。这是我正在使用的代码,其中没有必要的变量postedPictureUrl

private async void PostToWall_Click(object sender, RoutedEventArgs e)
{
    try
    {
        dynamic parameters = new ExpandoObject();
        parameters.message = txtMessage.Text;

        StorageFile imageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Images/photo.png"));
        IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read);
        var reader = new Windows.Storage.Streams.DataReader(fileStream.GetInputStreamAt(0));
        await reader.LoadAsync((uint)fileStream.Size);
        byte[] pixels = new byte[fileStream.Size];
        reader.ReadBytes(pixels);
        parameters.picture = new FacebookMediaObject
        {
            ContentType = "image/png",
            FileName = "photo.png",
        }.SetValue(pixels);
        dynamic result = await _fb.PostTaskAsync("me/photos", parameters);
        _lastMessageId = result.id;
        txtMessage.Text = string.Empty;
        btnDeleteLastMessage.IsEnabled = true;
        string postedPictureUrl = string.Format("https://graph.facebook.com/{0}/photos?&access_token={2}", _userId, _fb.AccessToken"); //this is where I need to retrieve the id of the photo...
        myPostedPainting.Source = new BitmapImage(new Uri(postedPictureUrl));
    }
    catch (FacebookApiException ex)
    {
        // handle error message
    }
}
4

0 回答 0